package main; import java.awt.*; import java.awt.image.*; public class Cell { int x, y, location; WineBottle bottle; BufferedImage img, brightImg; static BufferedImage bg, wideBg; public Cell(int x, int y, int location, WineBottle bottle, BufferedImage img, BufferedImage brightImg) { this.x = x; this.y = y; this.location = location; this.bottle = bottle; this.img = img; this.brightImg = brightImg; } int getX() { return x; } int getY() { return y; } int getLocation() { return location; } public void draw(Graphics g) { if(bottle != null && bottle.isSelected()) drawBright(g); else g.drawImage(img, x, y, null); } public void drawBright(Graphics g) { g.drawImage(brightImg, x, y, null); } public void drawDescription(Graphics g, int x, int y, Font font) { if(bottle == null) return; FontMetrics metrics = g.getFontMetrics(font); int height = 160; if(metrics.stringWidth(bottle.getName()) >= 120 || metrics.stringWidth("Variety: "+bottle.getVariety()) >= 120) g.drawImage(wideBg, x, y-height, null); else g.drawImage(bg, x, y-height, null); g.setColor(new Color(174, 11, 27)); g.setFont(font); g.drawString(bottle.getName(), x+5, y-height+20); g.drawString("Winery: "+bottle.getVineyard(), x+5, y-height+35); if(bottle.getVintage() == 0) g.drawString("Vintage Unknown", x+5, y-height+50); else g.drawString(Integer.toString(bottle.getVintage()), x+5, y-height+50); g.drawString("Country: "+bottle.getCountry(), x+5, y-height+65); g.drawString("Region: "+bottle.getRegion(), x+5, y-height+80); g.drawString("Variety: "+bottle.getVariety(), x+5, y-height+95); } }