public void paint(Graphics g) {
   Graphics2D g_2d = (Graphics2D) g;
   Ellipse2D ellipse = new Ellipse2D.Double(0, 2, 80, 80);
   Rectangle2D rect = new Rectangle2D.Double(40, 2, 80, 80);
   Area a1 = new Area(ellipse);
   Area a2 = new Area(rect);
   a1.intersect(a2); // "Óë"
   g_2d.fill(a1);
   ellipse.setFrame(130, 2, 80, 80);
   rect.setFrame(170, 2, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.add(a2); // "»ò"
   g_2d.draw(a1);
   ellipse.setFrame(0, 90, 80, 80);
   rect.setFrame(40, 90, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.subtract(a2); // "²î"
   g_2d.draw(a1);
   ellipse.setFrame(130, 90, 80, 80);
   rect.setFrame(170, 90, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.exclusiveOr(a2); // "Òì»ò"
   g_2d.fill(a1);
 }
Пример #2
0
    /** @see prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem) */
    @Override
    protected Shape getRawShape(VisualItem item) {
      double x1 = item.getDouble(VisualItem.X);
      double y1 = item.getDouble(VisualItem.Y);
      double x2 = item.getDouble(VisualItem.X2);
      double y2 = item.getDouble(VisualItem.Y2);
      boolean isX = item.getBoolean(DocumentGridAxisLayout.IS_X);
      double midPoint = item.getDouble(DocumentGridAxisLayout.MID_POINT);
      // horizontal or vertical coords should be manually held constant so that fisheye works
      // properly
      if (isX) {
        // vertical line
        m_line.setLine(x1, y1, x1, y2);
      } else {
        // horizontal line
        m_line.setLine(x1, y1, x2, y1);
      }

      if (!item.canGetString(VisualItem.LABEL)) {
        return m_line;
      }

      String label = item.getString(VisualItem.LABEL);
      if (label == null) {
        return m_line;
      }

      FontMetrics fm = DEFAULT_GRAPHICS.getFontMetrics(item.getFont());
      m_ascent = fm.getAscent();
      int h = fm.getHeight();
      int w = fm.stringWidth(label);

      double tx, ty;

      int labelOffset = 10;
      if (isX) {
        // vertical axis
        // get text x-coord, center at midPoint
        //            tx = x1 + (x2-x1)/2 - w/2;
        //            tx = midPoint + (x1+midPoint)/2 - w/2;
        //            tx = x1 + midPoint/2 - w/2;
        // simpler approach: just add a fixed distance
        tx = x1 + labelOffset;
        // get text y-coord
        ty = y2 - h;
      } else {
        // horiz axis
        // get text x-coord
        tx = x1 - w - 2;
        // get text y-coord, center at midPoint
        //            ty = y1 + (y2-y1)/2 - h/2;
        //            ty = y1 + midPoint/2 - h/2;
        // simpler approach: just add a fixed distance
        ty = y1 + labelOffset;
      }

      m_box.setFrame(tx, ty, w, h);
      return m_box;
    }
Пример #3
0
  public void addTriggerToParking(TaxiwayParkingModel model) {
    Rectangle2D square = ((java.awt.geom.Ellipse2D.Float) model.getParkingCircle()).getBounds2D();
    square.setFrame(
        square.getX() - (double) (20F * scale),
        square.getY() - (double) (20F * scale),
        square.getWidth() + (double) (40F * scale),
        square.getHeight() + (double) (40F * scale));
    TriggerModel triggerModel = new TriggerModel();
    triggerModel.setShouldNotify(false);
    triggerModel.setType73("YES");
    triggerModel.setTypeJet("YES");
    triggerModel.setShouldNotify(true);
    java.awt.geom.Point2D.Float point =
        new java.awt.geom.Point2D.Float(
            (float) (square.getX() + square.getWidth() / 2D),
            (float) (square.getY() + square.getHeight() / 2D));
    java.awt.geom.Point2D.Float vertexPoints[] = new java.awt.geom.Point2D.Float[4];
    vertexPoints[0] =
        Utilities.rotatePoint(
            point,
            new java.awt.geom.Point2D.Float((float) square.getX(), (float) square.getY()),
            model.getHeading());
    vertexPoints[1] =
        Utilities.rotatePoint(
            point,
            new java.awt.geom.Point2D.Float(
                (float) square.getX(), (float) (square.getY() + square.getHeight())),
            model.getHeading());
    vertexPoints[2] =
        Utilities.rotatePoint(
            point,
            new java.awt.geom.Point2D.Float(
                (float) (square.getX() + square.getWidth()),
                (float) (square.getY() + square.getHeight())),
            model.getHeading());
    vertexPoints[3] =
        Utilities.rotatePoint(
            point,
            new java.awt.geom.Point2D.Float(
                (float) (square.getX() + square.getWidth()), (float) square.getY()),
            model.getHeading());
    for (int i = 0; i < 4; i++) {
      VertexModel vertexModel = new VertexModel();
      vertexModel.setShouldNotify(false);
      vertexModel.setLatLon(
          Utilities.getLatLonForPixel(
              model.getCenterPoint().getLat(),
              model.getCenterPoint().getLon(),
              vertexPoints[i].getX(),
              vertexPoints[i].getY(),
              scale));
      vertexModel.setShouldNotify(true);
      triggerModel.addVertexModel(vertexModel);
    }

    addTriggerModel(triggerModel);
  }