Example #1
0
 private void fillArc(
     int x, int y, int width, int height, int startAngle, int arcAngle, int symbolType) {
   if (!Preferences.monochrome) {
     setFillColor(symbolType);
     gRef.fillArc(x, y, width, height, startAngle, arcAngle);
     restoreColor();
   }
 }
Example #2
0
      /**
       * A paint class that will draw the needle, dots, and TO/FROM RenderingHints is IMPORTANT. It
       * will make sure that everything stays focused and not blurry whenever the image rotates. I
       * added an empty line between the 8 fillArcs, just so its easier to see that four of them
       * draw on the left side and four draw on the right side.
       */
      public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        RenderingHints hints = new RenderingHints(null);
        hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        hints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        g2.setRenderingHints(hints);
        g2.setStroke(new BasicStroke(3));
        // g2.drawString("TO", 190, 200);
        if (vor.isTo() == true) {
          if (vor.isAbeamed() == true) {
            // g2.setFont(new Font("default", Font.BOLD, 16));
            // g2.setColor(Color.red);
            // g2.drawString("BAD", 190, 200);
          } else {
            // g2.setFont(new Font("default", Font.BOLD, 16));
            g2.drawString("TO", 190, 200);
          }
        } else if (vor.isFrom() == true) {
          if (vor.isAbeamed() == true) {
            // g2.setFont(new Font("default", Font.BOLD, 16));
            // g2.setColor(Color.red);
            // g2.drawString("BAD", 190, 300);
          } else {
            // g2.setFont(new Font("default", Font.BOLD, 13));
            g2.drawString("FROM", 190, 300);
          }
        } else if (vor.isFrom() == false || vor.isTo() == false) {
          // is above the vor station no to or from
        }

        g2.fillArc(140, 240, 7, 7, 0, 360);
        g2.fillArc(125, 240, 7, 7, 0, 360);
        g2.fillArc(110, 240, 7, 7, 0, 360);
        g2.fillArc(95, 240, 7, 7, 0, 360);

        g2.fillArc(195, 240, 7, 7, 0, 360);
        g2.fillArc(210, 240, 7, 7, 0, 360);
        g2.fillArc(225, 240, 7, 7, 0, 360);
        g2.fillArc(240, 240, 7, 7, 0, 360);

        // g2.drawString("FROM",190, 300);
        g2.drawLine(x, y1, x, y2);
        super.paintComponent(g);
        g2.dispose();
      }
  public void paintComponent(Graphics g) {
    setSize(xSize, ySize);
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;

    if (PedigreeExplorer.thickLines) {
      // turn this off so they don't look blurry when exported
      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    } else {
      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    }
    g2.setColor(Color.black);

    if (PedigreeExplorer.thickLines) {
      g2.setStroke(new BasicStroke(2));
    } else {
      g2.setStroke(new BasicStroke(1));
    }

    if (sex == male) {
      if (PedigreeExplorer.thickLines) {
        g2.drawRect(1, 1, symbolSize - 2, symbolSize - 2);
      } else {
        g2.drawRect(0, 0, symbolSize, symbolSize);
      }

      if (affection == affected) {
        g2.fillRect(0, 0, symbolSize, symbolSize);
      }
    }

    if (sex == female) {
      if (PedigreeExplorer.thickLines) {
        g2.drawArc(1, 1, symbolSize - 2, symbolSize - 2, 0, 360);
      } else {
        g2.drawArc(0, 0, symbolSize, symbolSize, 0, 360);
      }

      if (affection == affected) {
        g2.fillArc(0, 0, symbolSize, symbolSize, 0, 360);
      }
    }
  }
  /**
   * The GraphicDrawer.paint() Function allows the user to draw pre-defined graphics into a given
   * Graphics Object. The user may give the rectangle properties which defines at best the desired
   * area to draw with a Int id which requests the desired graphic, whenever it's vectorial or
   * raster graphics
   *
   * @author LuisArturo
   */
  public void paint(int id, Dimension r, Graphics g) {
    Graphics2D g2;
    switch (id) {
      case FILE:
        {
          g2 = (Graphics2D) g;
          try {
            FileInputStream img = new FileInputStream("archivo.png");
            BufferedImage in = ImageIO.read(img);
            g2.drawImage(
                in, r.width * 2 / 10, r.height * 2 / 10, r.width * 2 / 3, r.height * 2 / 3, null);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        break;
      case REDO:
        {
          g2 = (Graphics2D) g;
          g2.setColor(color);
          g2.fillArc(
              r.width * 2 / 10, r.height * 2 / 10, r.width * 6 / 10, r.height * 6 / 10, 270, 225);
          Polygon p = new Polygon();
          p.addPoint(r.width * 2 / 10, r.height * 2 / 10);
          p.addPoint(r.width * 2 / 10, r.height * 5 / 10);
          p.addPoint(r.width * 5 / 10, r.height * 5 / 10);
          g2.fillPolygon(p);
          g2.setColor(g2.getBackground());
          g2.fillArc(
              r.width * 3 / 10, r.height * 3 / 10, r.width * 4 / 10, r.height * 4 / 10, 270, 225);
        }
        break;
      case TEXT:
        {
          g2 = (Graphics2D) g;
          g2.setColor(color);
          g2.setFont(new Font("Serif", Font.ITALIC | Font.BOLD, r.height * 6 / 10));
          g2.drawChars("A".toCharArray(), 0, 1, r.width * 3 / 10, r.height * 7 / 10);
        }
        break;
      case SELECT:
        {
          g2 = (Graphics2D) g;
          try {
            FileInputStream img = new FileInputStream("mano.png");
            BufferedImage in = ImageIO.read(img);
            g2.drawImage(
                in, r.width * 1 / 10, r.height * 1 / 10, r.width * 2 / 3, r.height * 2 / 3, null);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        break;
      case PENCIL:
        {
          g2 = (Graphics2D) g;
          try {
            FileInputStream img = new FileInputStream("lapiz.png");
            BufferedImage in = ImageIO.read(img);
            g2.drawImage(
                in, r.width * 2 / 10, r.height * 2 / 10, r.width * 2 / 3, r.height * 2 / 3, null);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        break;

      case ARROW:
        {
          g2 = (Graphics2D) g;
          try {
            FileInputStream img = new FileInputStream("arrow.png");
            BufferedImage in = ImageIO.read(img);
            g2.drawImage(
                in, r.width * 2 / 10, r.height * 2 / 10, r.width * 2 / 3, r.height * 2 / 3, null);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        break;
      case ZOOM:
        {
          g2 = (Graphics2D) g;
          try {
            FileInputStream img = new FileInputStream("zoom.png");
            BufferedImage in = ImageIO.read(img);
            g2.drawImage(
                in, r.width * 2 / 10, r.height * 2 / 10, r.width * 2 / 3, r.height * 2 / 3, null);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        break;
    }
  }
Example #5
0
 private void clearArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
   penColor = gRef.getColor();
   gRef.setColor(Preferences.backgroundColor);
   gRef.fillArc(x, y, width, height, startAngle, arcAngle);
   gRef.setColor(penColor);
 }
Example #6
0
 // also clip, transform, composite,
 // public boolean isOpaque(){return false;}//theOpaque!=null&&theOpaque;}
 // ---------------------------------------------------------
 private void doPaint(Graphics2D g, int s, Object o) {
   // process an operation from the buffer
   // System.out.println(s);
   Object o1 = null,
       o2 = null,
       o3 = null,
       o4 = null,
       o5 = null,
       o6 = null,
       o7 = null,
       o8 = null,
       o9 = null,
       o10 = null,
       o11 = null;
   if (o instanceof Object[]) {
     Object[] a = (Object[]) o;
     if (a.length > 0) o1 = a[0];
     if (a.length > 1) o2 = a[1];
     if (a.length > 2) o3 = a[2];
     if (a.length > 3) o4 = a[3];
     if (a.length > 4) o5 = a[4];
     if (a.length > 5) o6 = a[5];
     if (a.length > 6) o7 = a[6];
     if (a.length > 7) o8 = a[7];
     if (a.length > 8) o9 = a[8];
     if (a.length > 9) o10 = a[9];
     if (a.length > 10) o11 = a[10];
   }
   switch (s) {
     case clear:
       paintBackground(g, theBackground);
       break;
       // public void addRenderingHints(Map<?,?> hints)
       // {toBuffer("addRenderingHints",hints );}
     case addRenderingHints:
       g.addRenderingHints((Map<?, ?>) o);
       break;
     case clip1:
       g.clip((Shape) o);
       break;
     case draw1:
       g.draw((Shape) o);
       break;
     case draw3DRect:
       g.draw3DRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Boolean) o5);
       break;
     case drawGlyphVector:
       g.drawGlyphVector((GlyphVector) o1, (Float) o2, (Float) o3);
       break;
     case drawImage1:
       g.drawImage((BufferedImage) o1, (BufferedImageOp) o2, (Integer) o3, (Integer) o4);
       break;
     case drawImage2:
       g.drawImage((Image) o1, (AffineTransform) o2, (ImageObserver) o3);
       break;
     case drawRenderableImage:
       g.drawRenderableImage((RenderableImage) o1, (AffineTransform) o2);
       break;
     case drawRenderedImage:
       g.drawRenderedImage((RenderedImage) o1, (AffineTransform) o2);
       break;
     case drawString1:
       g.drawString((AttributedCharacterIterator) o1, (Float) o2, (Float) o3);
       break;
     case drawString2:
       g.drawString((AttributedCharacterIterator) o1, (Integer) o2, (Integer) o3);
       break;
     case drawString3:
       g.drawString((String) o1, (Float) o2, (Float) o3);
       break;
     case drawString4:
       g.drawString((String) o1, (Integer) o2, (Integer) o3);
       break;
     case fill:
       g.fill((Shape) o);
       break;
     case fill3DRect:
       g.fill3DRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Boolean) o5);
       break;
     case rotate1:
       g.rotate((Double) o);
       break;
     case rotate2:
       g.rotate((Double) o1, (Double) o2, (Double) o3);
       break;
     case scale1:
       g.scale((Double) o1, (Double) o2);
       break;
     case setBackground:
       g.setBackground(
           (Color) o); // paintBackground(g,(Color)o); /*super.setBackground((Color)o) ;*/
       break;
     case setComposite:
       g.setComposite((Composite) o);
       break;
     case setPaint:
       g.setPaint((Paint) o);
       break;
     case setRenderingHint:
       g.setRenderingHint((RenderingHints.Key) o1, o2);
       break;
     case setRenderingHints:
       g.setRenderingHints((Map<?, ?>) o);
       break;
     case setStroke:
       g.setStroke((Stroke) o);
       break;
     case setTransform:
       g.setTransform(makeTransform(o));
       break;
     case shear:
       g.shear((Double) o1, (Double) o2);
       break;
     case transform1:
       g.transform(makeTransform(o));
       break;
     case translate1:
       g.translate((Double) o1, (Double) o2);
       break;
     case translate2:
       g.translate((Integer) o1, (Integer) o2);
       break;
     case clearRect:
       g.clearRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case copyArea:
       g.copyArea(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case drawArc:
       g.drawArc(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case drawBytes:
       g.drawBytes((byte[]) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5);
       break;
     case drawChars:
       g.drawChars((char[]) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5);
       break;
     case drawImage4:
       g.drawImage((Image) o1, (Integer) o2, (Integer) o3, (Color) o4, (ImageObserver) o5);
       break;
     case drawImage5:
       g.drawImage((Image) o1, (Integer) o2, (Integer) o3, (ImageObserver) o4);
       break;
     case drawImage6:
       g.drawImage(
           (Image) o1,
           (Integer) o2,
           (Integer) o3,
           (Integer) o4,
           (Integer) o5,
           (Color) o6,
           (ImageObserver) o7);
       break;
     case drawImage7:
       g.drawImage(
           (Image) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (ImageObserver) o6);
       break;
     case drawImage8:
       g.drawImage(
           (Image) o1,
           (Integer) o2,
           (Integer) o3,
           (Integer) o4,
           (Integer) o5,
           (Integer) o6,
           (Integer) o7,
           (Integer) o8,
           (Integer) o9,
           (Color) o10,
           (ImageObserver) o11);
       break;
     case drawImage9:
       g.drawImage(
           (Image) o1,
           (Integer) o2,
           (Integer) o3,
           (Integer) o4,
           (Integer) o5,
           (Integer) o6,
           (Integer) o7,
           (Integer) o8,
           (Integer) o9,
           (ImageObserver) o10);
       break;
     case drawLine:
       g.drawLine((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case drawOval:
       g.drawOval((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case drawPolygon1:
       g.drawPolygon((int[]) o1, (int[]) o2, (Integer) o3);
       break;
     case drawPolygon2:
       g.drawPolygon((Polygon) o);
       break;
     case drawPolyline:
       g.drawPolyline((int[]) o1, (int[]) o2, (Integer) o3);
       break;
     case drawRect:
       g.drawRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case drawRoundRect:
       g.drawRoundRect(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case fillArc:
       g.fillArc(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case fillOval:
       g.fillOval((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
       // {toBuffer("fillPolygon",mkArg(xPoints,  yPoints, nPoints) );}
     case fillPolygon1:
       g.fillPolygon((int[]) o1, (int[]) o2, (Integer) o3);
       break;
     case fillPolygon2:
       g.fillPolygon((Polygon) o);
       break;
     case fillRect:
       g.fillRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4);
       break;
     case fillRoundRect:
       g.fillRoundRect(
           (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6);
       break;
     case setClip1:
       g.setClip((Shape) o);
       break;
     case setColor:
       g.setColor((Color) o);
       break;
     case setFont:
       g.setFont((Font) o);
       break;
     case setPaintMode:
       g.setPaintMode();
       break;
     case setXORMode:
       g.setXORMode((Color) o);
       break;
     case opaque:
       super.setOpaque((Boolean) o);
       break;
     case drawOutline: // g.drawString((String)o1, (Integer)o2, (Integer)o3) ;break;
       {
         FontRenderContext frc = g.getFontRenderContext();
         TextLayout tl = new TextLayout((String) o1, g.getFont(), frc);
         Shape s1 = tl.getOutline(null);
         AffineTransform af = g.getTransform();
         g.translate((Integer) o2, (Integer) o3);
         g.draw(s1);
         g.setTransform(af);
       }
       ;
       break;
     default:
       System.out.println("Unknown image operation " + s);
   }
 }