Package jmt.engine.jaba

Examples of jmt.engine.jaba.DPoint


    this.yTranslation = value;
    this.repaint();
  }

  public DPoint adjustMousePoint(int x, int y) {
    return new DPoint(x / currentScale + xTranslation, y / currentScale
        + yTranslation);
  }
View Full Code Here


  public void place(Graphics2D g, int xCoord) {
    int i;
    int previousY, newY;
    String l;
    DPoint p;
    FontMetrics fm;

    p = points.get(0);
    l = labels.get(0);
    previousY = Integer.MAX_VALUE;
    for (i = 0; i < labels.size(); i++) {
      l = labels.get(labels.size() - i - 1);
      p = points.get(points.size() - i - 1);
      fm = g.getFontMetrics();

      if (fm != null) {
        if (p.getY() + fm.getStringBounds(l, g).getHeight()
            + DISTANCE_BETWEEN_TWO_LABELS > previousY) {
          // overlapping
          newY = (int) (previousY
              - fm.getStringBounds(l, g).getHeight() - DISTANCE_BETWEEN_TWO_LABELS);
        } else {
          newY = (int) p.getY();
        }
        g.drawString(l, xCoord + 1,
            (int) (newY + fm.getStringBounds(l, g).getHeight() / 4));
      } else {
        if (p.getY() + DISTANCE_BETWEEN_TWO_LABELS > previousY) {
          // overlapping
          newY = (int) (previousY - DISTANCE_BETWEEN_TWO_LABELS);
        } else {
          newY = (int) p.getY();
        }
        g.drawString(l, xCoord + 1, (int) (newY));
      }
      g.draw(new Line2D.Double(p.getX(), p.getY(), xCoord, newY));
      previousY = newY;
    }
  }
View Full Code Here

  public void place(Graphics2D g, int yLabelCoord, int yMarkCoord) {
    int i;
    int previousX, newX, y;
    String l;
    DPoint p;
    FontMetrics fm;

    p = points.get(0);
    l = labels.get(0);
    previousX = 0;
    for (i = 0; i < labels.size(); i++) {
      l = labels.get(i);
      p = points.get(i);
      fm = g.getFontMetrics();
      newX = (int) (p.getX() - fm.getStringBounds(l, g).getWidth() / 2);
      if (newX < previousX + DISTANCE_BETWEEN_TWO_LABELS) {
        continue;
      }
      if (i % 2 == 0)
        y = yLabelCoord;
      else
        y = yLabelCoord + ODD_ADJUSTMENT;
      g.drawString(l, newX, y);
      g.draw(new Line2D.Double(p.getX(), yMarkCoord - MARK_WIDTH / 2, p
          .getX(), yMarkCoord + MARK_WIDTH / 2));
      previousX = (int) (newX + fm.getStringBounds(l, g).getWidth());
    }
  }
View Full Code Here

  public void place(Graphics2D g, int xCoord) {
    int i;
    int newY;
    String l;
    DPoint p;
    FontMetrics fm;
   
    if(points == null || points.size()==0)
      return;

    p = points.get(0);
    l = labels.get(0);
    newY = 0;
    for (i = 0; i < labels.size(); i++) {
      l = labels.get(labels.size() - i - 1);
      p = points.get(points.size() - i - 1);
      fm = g.getFontMetrics();
      // if (p.getY() + fm.getStringBounds(l, g).getHeight()
      // + DistanceBetweenTwoLabels > previousY) {
      // overlapping
      // } else {
      //
      // }
      newY = (int) p.getY();
      g.drawString(l, xCoord, (int) (newY + fm.getStringBounds(l, g)
          .getHeight() / 4));
      // previousY = newY;
    }
  }
View Full Code Here

   * @param allDominants The vector with all the points
   * @param height The height of the window
   * @param width The width of the window
   */
  public PainterConvex2D(Vector<Point2D> allDominants, int height, int width) {
    DPoint p;

    for (int i = 0; i < allDominants.size(); i++) {
      p = (DPoint) allDominants.get(i);
      if (p.getX() > maxValue) {
        maxValue = p.getX();
      }

      if (p.getY() > maxValue) {
        maxValue = p.getY();
      }

      if (p.getLabel().toString().length() > maxLabel) {
        maxLabel = p.getLabel().toString().length();
      }

    }

    //Max value in the graphic
View Full Code Here

    //The first color in the maskedoff color beacause after will be draw
    //the non-maskedoff areas
    g.setColor(maskedoff);
    Polygon poly = new Polygon();

    DPoint p;
    p = (DPoint) allConvex.get(0);

    poly.addPoint((int) (p.getX() * scale) + tran_x, tran_y);

    //Add the point a the polygon for paint the convex area
    for (int i = 0; i < allConvex.size(); i++) {
      p = (DPoint) allConvex.get(i);
      poly.addPoint((int) (p.getX() * scale) + tran_x, tran_y - (int) (p.getY() * scale));
    }

    p = (DPoint) allConvex.get(allConvex.size() - 1);
    poly.addPoint(1 + tran_x, tran_y - (int) (p.getY() * scale));
    poly.addPoint(1 + tran_x, tran_y);
    g.fillPolygon(poly);
    g.setColor(Color.GRAY);
    g.drawPolygon(poly);

    //Draw the non-maskedoff area for each dominant point
    Polygon masked = new Polygon();
    g.setColor(area);

    int k = 0;
    for (k = 0; k < allDominants.size() - 1; k++) {
      p = (DPoint) allDominants.get(k);
      if (!p.intEquals((DPoint) allDominants.get(k + 1))) {
        masked = twoPointRectangle(1 + tran_x, tran_y, (int) (p.getX() * scale) + tran_x, tran_y - (int) (p.getY() * scale));
        g.fillPolygon(masked);
      }
    }
    //Last area is 1 point small
    p = (DPoint) allDominants.get(k);
    masked = twoPointRectangle(1 + tran_x, tran_y, (int) (p.getX() * scale) + tran_x, tran_y - (int) (p.getY() * scale) + 1);
    g.fillPolygon(masked);
  }
View Full Code Here

    int fontSize = 7 + pointSize;
    Font f = new Font("Arial", Font.PLAIN, fontSize);
    g.setFont(f);

    for (int i = 0; i < points.size(); i++) {
      DPoint p = (DPoint) points.get(i);
      if (!p.isSelect()) {
        g.drawString(p.getLabel(), tran_x + (int) (p.getX() * scale) - 15, tran_y - (int) (p.getY() * scale) - 3 - pointSize);
      } else {
        g.drawString(p.getLabel() + " (" + format2Dec.format(p.getX()) + ", " + format2Dec.format(p.getY()) + ")", tran_x
            + (int) (p.getX() * scale) - 15, tran_y - (int) (p.getY() * scale) - 3 - pointSize);
      }
    }
  }
View Full Code Here

   * @param g The graphic object
   * @param dominant The vector with the dominant points
   * @param dominates The vector with the dominates points
   */
  public void drawDominantArrow(Graphics2D g, Vector<Point2D> dominant, Vector<Point2D> dominates) {
    DPoint p;
    DPoint p2;
    boolean first = true;

    for (int i = 0; i < dominates.size(); i++) {
      p = (DPoint) dominates.get(i);
      if (p.isSelect()) {
        for (int k = dominant.size() - 1; k >= 0; k--) {
          p2 = (DPoint) dominant.get(k);
          if (p2.isSelect()) {

            g.setColor(Color.magenta);
            //Draw Arrow

            //The angle is calculete throw the rotator point
            DPoint rotator = new DPoint(p2.getX() - p.getX(), p2.getY() - p.getY());
            double angle = rotator.polarAngle();
            //The thestination point in not into the point but near the point
            int xPoint = (int) (p.getX() * scale) + tran_x + (int) (pointSize * Math.cos(angle));
            int yPoint = tran_y - (int) (p.getY() * scale) - (int) (pointSize * Math.sin(angle));

            g.drawLine(xPoint, yPoint, (int) (p2.getX() * scale) + tran_x, tran_y - (int) (p2.getY() * scale));
 
View Full Code Here

   * @param width
   *            The width of the window
   */
  public Convex2DGraph(JabaModel data, JabaWizard mainWin) {
    super();
    DPoint p;

    this.setBorder(BorderFactory.createEtchedBorder());
    this.setBackground(BGCOLOR);

    addMouseListener(this);
    addMouseMotionListener(this);

    this.mainWin = mainWin;
    this.data = data;
    this.mouseButtonPress = 0;
    this.selectedPoint = null;
    this.selectedConvexSegment = null;
    this.dragging = false;
    this.dragPoint = new Point(0, 0);
    this.xMaxValue = 0;
    this.yMaxValue = 0;
    this.showAllLabels = true;
    this.filterStationLabel = new boolean[data.getStations()];
    for (int i = 0; i < data.getStations(); i++) {
      this.filterStationLabel[i] = false;
    }

    for (int i = 0; i < data.getResults().getAllDominants().size(); i++) {
      p = (DPoint) data.getResults().getAllDominants().get(i);
      if (p.getX() > xMaxValue) {
        xMaxValue = p.getX();
      }

      if (p.getY() > yMaxValue) {
        yMaxValue = p.getY();
      }
    }

  }
View Full Code Here

  public void paint(Graphics g) {
    super.paint(g);

    Graphics2D g2;
    DPoint graphOrigin;

    g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);

    g2.setColor(LINES_COLOR);
    try {
      graphOrigin = new DPoint(GRAPH_LEFT_MARGIN, getHeight()
          - GRAPH_BOTTOM_MARGIN);
      plane = new CartesianPositivePlane(
          g2,
          graphOrigin,
          (int) (getWidth() - GRAPH_LEFT_MARGIN - GRAPH_RIGHT_MARGIN),
          (int) (getHeight() - GRAPH_TOP_MARGIN - GRAPH_BOTTOM_MARGIN),
          xMaxValue, yMaxValue);
    } catch (Exception e) {
      return;
    }
    fillArea(g2, data.getResults().getAllConvex(), Color.orange);
    for (Point2D p : data.getResults().getDominants()) {
      drawMaskedOffRectangle(g2, p, new Color(255, 250, 120));
    }
    drawArea(g2, data.getResults().getAllConvex(), Color.gray);
    if (showAllLabels) {
      drawPoint(g2, data.getResults().getDominants(), Color.blue,
          getPointSize() + 1);
      drawPoint(g2, data.getResults().getDominates(), new Color(15, 185,
          100), getPointSize() + 1);
      drawPoint(g2, data.getResults().getFiltDominants(), Color.black,
          getPointSize() + 1);
      drawPoint(g2, data.getResults().getFiltDominates(), Color.gray,
          getPointSize() + 1);
      drawPoint(g2, data.getResults().getFiltConvex(), Color.black,
          getPointSize() + 1);
      pointLabel(g2, data.getResults().getPoints());
    } else {
      pointLabel(g2, data.getResults().getConvex());
    }
    drawPoint(g2, data.getResults().getConvex(), Color.red,
        getPointSize() + 3);

    if (selectedConvexSegment != null) {
      drawSelectLine(g2, selectedConvexSegment.getP1(),
          selectedConvexSegment.getP2());
    }

    summary(g2);
    /*
     * // drawSelectLine(g2, lineP1, lineP2, s3d, // data.getClassNames());
     * drawDominantArrow(g2, data.getResults().getDominants(),
     * data.getResults().getDominates()); drawFiltArea(g2,
     * data.getResults().getFilteredArea());
     */
    g2.setColor(LINES_COLOR);

    ArrayList<DPoint> points = new ArrayList<DPoint>();
    for (int i = 0; i <= NUM_OF_MARK_ON_X_AXIS; i++) {
      points.add(new DPoint(i * xMaxValue / NUM_OF_MARK_ON_X_AXIS, 0));
    }
    plane.drawValuesOnXAxis(points);

    points = new ArrayList<DPoint>();
    for (int i = NUM_OF_MARK_ON_Y_AXIS; i > 0; i--) {
      points.add(new DPoint(0, i * yMaxValue / NUM_OF_MARK_ON_Y_AXIS));
    }
    plane.drawValuesOnYAxis(points);

    plane.draw(data.getClassNames()[0], data.getClassNames()[1]);
    if (filtering || unFiltering) {
View Full Code Here

TOP

Related Classes of jmt.engine.jaba.DPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.