/** Update - Method, implements double buffering */ public void update(Graphics g) { // initialize buffer if (dbImage == null) { dbImage = createImage(this.getSize().width, this.getSize().height); dbg = dbImage.getGraphics(); } // clear screen in background dbg.setColor(getBackground()); dbg.fillRect(0, 0, this.getSize().width, this.getSize().height); // draw elements in background dbg.setColor(getForeground()); paint(dbg); // draw image on the screen g.drawImage(dbImage, 0, 0, this); }
public void draw(Graphics g, ImageObserver ob) { if (!todraw) { g.setColor(bgcolor); g.drawRect(x, y, w + 2 * border, h + 2 * border); g.fillRect(x, y, w + 2 * border, h + 2 * border); return; } if (selected) g.setColor(selected_color); else g.setColor(unselected_color); g.drawRect(x, y, w + 2 * border, h + 2 * border); g.fillRect(x, y, w + 2 * border, h + 2 * border); g.drawImage(image[im], x + border, y + border, ob); // g.setColor(Color.black); // g.drawString("" + im,x+5,y+5); }
/** * This generates the sector image for the specific planet. Will generate from 10,10 on the sector * list . */ public Graphics wantSmallPlanetFrame(Graphics g, int x, int y, int zoomFactor, JPanel p) { // p.getGraphics().drawImage(smallPlanets[planetType], x, y, zoomFactor*25, zoomFactor*25, p); // darkgray gray lightgrey orange pink blue red black white if (planetType == VERONIAN) { g.drawImage( Planets[0], x + 10 * zoomFactor, y + 10 * zoomFactor, 20 * zoomFactor, 20 * zoomFactor, p); // g.setColor(Color.orange); // g.drawOval(x+10*zoomFactor, y+10*zoomFactor, 20*zoomFactor, 20*zoomFactor); // g.fillOval(x+10*zoomFactor, y+10*zoomFactor, 20*zoomFactor, 20*zoomFactor); // System.out.println("type" + planetType); } if (planetType == ERIS) { g.drawImage( Planets[1], x + 10 * zoomFactor, y + 10 * zoomFactor, 20 * zoomFactor, 20 * zoomFactor, p); // g.setColor(Color.blue); // g.drawOval(x+5*zoomFactor, y+5*zoomFactor, 14*zoomFactor, 14*zoomFactor); // g.fillOval(x+5*zoomFactor, y+5*zoomFactor, 14*zoomFactor, 14*zoomFactor); // System.out.println("type" + planetType); } if (planetType == TIERRAN) { g.drawImage( Planets[2], x + 10 * zoomFactor, y + 10 * zoomFactor, 20 * zoomFactor, 20 * zoomFactor, p); // g.setColor(Color.red); // g.drawOval(x+5*zoomFactor, y+5*zoomFactor, 23*zoomFactor, 23*zoomFactor); // g.fillOval(x+5*zoomFactor, y+5*zoomFactor, 23*zoomFactor, 23*zoomFactor); // System.out.println("type" + planetType); } if (planetType == ADONIS) { g.setColor(Color.green); g.drawOval(x + 5 * zoomFactor, y + 5 * zoomFactor, 20 * zoomFactor, 20 * zoomFactor); g.fillOval(x + 5 * zoomFactor, y + 5 * zoomFactor, 20 * zoomFactor, 20 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == THESBAN) { g.setColor(Color.magenta); g.drawOval(x + 8 * zoomFactor, y + 8 * zoomFactor, 9 * zoomFactor, 9 * zoomFactor); g.fillOval(x + 8 * zoomFactor, y + 8 * zoomFactor, 9 * zoomFactor, 9 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == TOMEKO) { g.setColor(Color.gray); g.drawOval(x + 2 * zoomFactor, y + 25 * zoomFactor, 22 * zoomFactor, 22 * zoomFactor); g.fillOval(x + 2 * zoomFactor, y + 25 * zoomFactor, 22 * zoomFactor, 22 * zoomFactor); g.setColor(Color.red); g.drawOval(x + 8 * zoomFactor, y + 32 * zoomFactor, 9 * zoomFactor, 9 * zoomFactor); g.fillOval(x + 8 * zoomFactor, y + 32 * zoomFactor, 9 * zoomFactor, 9 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == RING) { int moo = 1; // int moo = randy.nextInt(4)+1; if (moo == 1) { g.setColor(Color.blue); } if (moo == 0) { g.setColor(Color.green); } if (moo == 2) { g.setColor(Color.orange); } if (moo == 3) { g.setColor(Color.red); } g.drawOval(x + 25 * zoomFactor, y + 30 * zoomFactor, 10 * zoomFactor, 10 * zoomFactor); g.fillOval(x + 25 * zoomFactor, y + 30 * zoomFactor, 10 * zoomFactor, 10 * zoomFactor); moo = randy.nextInt(4) + 1; if (moo == 3) { g.setColor(Color.blue); } if (moo == 2) { g.setColor(Color.green); } if (moo == 1) { g.setColor(Color.orange); } if (moo == 0) { g.setColor(Color.red); } g.drawOval(x + 23 * zoomFactor, y + 28 * zoomFactor, 14 * zoomFactor, 14 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == CRACK) { int moo = randy.nextInt(4) + 1; if (moo == 1) { g.setColor(Color.blue); } if (moo == 0) { g.setColor(Color.green); } if (moo == 2) { g.setColor(Color.orange); } if (moo == 3) { g.setColor(Color.red); } g.drawOval(x + 2 * zoomFactor, y + 2 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.fillOval(x + 2 * zoomFactor, y + 2 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); moo = randy.nextInt(4) + 1; if (moo == 1) { g.setColor(Color.blue); } if (moo == 0) { g.setColor(Color.green); } if (moo == 2) { g.setColor(Color.orange); } if (moo == 3) { g.setColor(Color.red); } g.drawOval(x + 5 * zoomFactor, y + 5 * zoomFactor, 20 * zoomFactor, 20 * zoomFactor); moo = randy.nextInt(4) + 1; if (moo == 1) { g.setColor(Color.blue); } if (moo == 0) { g.setColor(Color.green); } if (moo == 2) { g.setColor(Color.orange); } if (moo == 3) { g.setColor(Color.red); } g.drawOval(x + 5 * zoomFactor, y + 5 * zoomFactor, 15 * zoomFactor, 15 * zoomFactor); moo = randy.nextInt(4) + 1; if (moo == 1) { g.setColor(Color.blue); } if (moo == 0) { g.setColor(Color.green); } if (moo == 2) { g.setColor(Color.orange); } if (moo == 3) { g.setColor(Color.red); } g.drawOval(x + 8 * zoomFactor, y + 8 * zoomFactor, 10 * zoomFactor, 10 * zoomFactor); moo = randy.nextInt(4) + 1; if (moo == 1) { g.setColor(Color.blue); } if (moo == 0) { g.setColor(Color.green); } if (moo == 2) { g.setColor(Color.orange); } if (moo == 3) { g.setColor(Color.red); } g.drawOval(x + 8 * zoomFactor, y + 8 * zoomFactor, 5 * zoomFactor, 5 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == TITAN) { g.setColor(Color.darkGray); g.drawOval(x + 22 * zoomFactor, y + 5 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.fillOval(x + 22 * zoomFactor, y + 5 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.setColor(Color.lightGray); g.drawOval(x + 28 * zoomFactor, y + 13 * zoomFactor, 10 * zoomFactor, 10 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == STEALTH) { g.setColor(Color.black); g.drawOval(x + 2 * zoomFactor, y + 2 * zoomFactor, 4 * zoomFactor, 4 * zoomFactor); g.fillOval(x + 2 * zoomFactor, y + 2 * zoomFactor, 4 * zoomFactor, 4 * zoomFactor); g.setColor(Color.white); g.drawOval(x + 4 * zoomFactor, y + 4 * zoomFactor, 2 * zoomFactor, 2 * zoomFactor); g.fillOval(x + 4 * zoomFactor, y + 4 * zoomFactor, 2 * zoomFactor, 2 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == SPARTAN) { g.setColor(Color.red); g.drawOval(x + 20 * zoomFactor, y + 20 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.fillOval(x + 20 * zoomFactor, y + 20 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.setColor(Color.orange); g.drawOval(x + 31 * zoomFactor, y + 31 * zoomFactor, 3 * zoomFactor, 3 * zoomFactor); g.fillOval(x + 31 * zoomFactor, y + 31 * zoomFactor, 3 * zoomFactor, 3 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == IONIS) { g.setColor(Color.lightGray); g.drawOval(x + 18 * zoomFactor, y + 25 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.fillOval(x + 18 * zoomFactor, y + 25 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == PEYO) { g.setColor(Color.blue); g.drawOval(x + 28 * zoomFactor, y + 16 * zoomFactor, 15 * zoomFactor, 15 * zoomFactor); g.fillOval(x + 28 * zoomFactor, y + 16 * zoomFactor, 15 * zoomFactor, 15 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == RIEHL) { g.setColor(Color.pink); g.drawOval(x + 5 * zoomFactor, y + 5 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.fillOval(x + 5 * zoomFactor, y + 5 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.setColor(Color.orange); g.drawOval(x + 9 * zoomFactor, y + 9 * zoomFactor, 17 * zoomFactor, 17 * zoomFactor); g.fillOval(x + 9 * zoomFactor, y + 9 * zoomFactor, 17 * zoomFactor, 17 * zoomFactor); g.setColor(Color.yellow); g.drawOval(x + 13 * zoomFactor, y + 13 * zoomFactor, 10 * zoomFactor, 10 * zoomFactor); g.fillOval(x + 13 * zoomFactor, y + 13 * zoomFactor, 10 * zoomFactor, 10 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == SARENA) { g.setColor(Color.orange); g.drawOval(x + 12 * zoomFactor, y + 12 * zoomFactor, 9 * zoomFactor, 9 * zoomFactor); g.fillOval(x + 12 * zoomFactor, y + 12 * zoomFactor, 9 * zoomFactor, 9 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == XIAN) { g.setColor(Color.red); g.drawOval(x + 35 * zoomFactor, y + 35 * zoomFactor, 10 * zoomFactor, 10 * zoomFactor); g.fillOval(x + 35 * zoomFactor, y + 35 * zoomFactor, 10 * zoomFactor, 10 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == BETHELLEN) { g.setColor(Color.white); g.drawOval(x + 30 * zoomFactor, y + 8 * zoomFactor, 15 * zoomFactor, 15 * zoomFactor); g.fillOval(x + 30 * zoomFactor, y + 8 * zoomFactor, 15 * zoomFactor, 15 * zoomFactor); g.setColor(Color.gray); g.drawOval(x + 13 * zoomFactor, y + 13 * zoomFactor, 6 * zoomFactor, 6 * zoomFactor); g.fillOval(x + 13 * zoomFactor, y + 13 * zoomFactor, 6 * zoomFactor, 6 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == MIRRIAN) { g.setColor(Color.cyan); g.drawOval(x + 20 * zoomFactor, y + 20 * zoomFactor, 20 * zoomFactor, 20 * zoomFactor); g.fillOval(x + 20 * zoomFactor, y + 20 * zoomFactor, 20 * zoomFactor, 20 * zoomFactor); // System.out.println("type" + planetType); } if (planetType == ADANMA) { g.setColor(Color.red); g.drawOval(x + 28 * zoomFactor, y + 28 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.fillOval(x + 28 * zoomFactor, y + 28 * zoomFactor, 25 * zoomFactor, 25 * zoomFactor); g.setColor(Color.green); g.drawOval(x + 10 * zoomFactor, y + 10 * zoomFactor, 9 * zoomFactor, 9 * zoomFactor); g.fillOval(x + 10 * zoomFactor, y + 10 * zoomFactor, 9 * zoomFactor, 9 * zoomFactor); // System.out.println("type" + planetType); } // g.setColor(color); // g.drawOval(x+1*zoomFactor, y+1*zoomFactor, 7*zoomFactor, 7*zoomFactor); // g.fillOval(x+1*zoomFactor, y+1*zoomFactor, 7*zoomFactor, 7*zoomFactor); return g; }