Examples of DPoint


Examples of jmt.engine.jaba.DPoint

   * @param maskedoff
   *            The vector with the masked-off points
   */
  public void drawArea(Graphics2D g, Vector<Point2D> allConvex, Color color) {
    Polygon poly = new Polygon();
    DPoint p;

    poly.addPoint(plane.getTrueX(0), plane.getTrueY(0));
    poly.addPoint(plane.getTrueX(xMaxValue), plane.getTrueY(0));
    // 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(plane.getTrueX(p.getX()), plane.getTrueY(p.getY()));
    }
    poly.addPoint(plane.getTrueX(0), plane.getTrueY(yMaxValue));

    g.setStroke(LINES);
    g.setColor(color);
View Full Code Here

Examples of jmt.engine.jaba.DPoint

    g.drawPolygon(poly);
  }

  public void fillArea(Graphics2D g, Vector<Point2D> allConvex, Color color) {
    Polygon poly = new Polygon();
    DPoint p;

    poly.addPoint(plane.getTrueX(0), plane.getTrueY(0));
    poly.addPoint(plane.getTrueX(xMaxValue), plane.getTrueY(0));
    // 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(plane.getTrueX(p.getX()), plane.getTrueY(p.getY()));
    }
    poly.addPoint(plane.getTrueX(0), plane.getTrueY(yMaxValue));

    g.setStroke(LINES);
    g.setColor(color);
View Full Code Here

Examples of jmt.engine.jaba.DPoint

    int fontSize = 7 + getPointSize();
    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 (selectedPoint == p && dragging) {
        drawShadowPoint(g, dragPoint, Color.BLACK, getPointSize() + 1);
      }
      if (p == selectedPoint) {
        g.drawString(
            p.getLabel() + " (" + FORMAT_3_DEC.format(p.getX())
                + ", " + FORMAT_3_DEC.format(p.getY()) + ")",
            plane.getTrueX(p.getX()) - 15, plane.getTrueY(p.getY())
                - 3 - getPointSize());
      } else {
        if (!filterStationLabel[i])
          g.drawString(p.getLabel(), plane.getTrueX(p.getX()) - 15,
              plane.getTrueY(p.getY()) - 3 - getPointSize());

      }
    }

  }
View Full Code Here

Examples of jmt.engine.jaba.DPoint

  }

  public void mouseMoved(MouseEvent e) {
    dragPoint = adjustMousePoint2(e.getX(), e.getY());
    Vector<Point2D> point = data.getResults().getAllPoints();
    DPoint p;

    selectedPoint = null;
    selectedConvexSegment = null;
    dragging = false;
    // If the mouse pass over a point, the mouse change
    for (int i = 0; i < point.size(); i++) {
      p = (DPoint) point.get(i);
      if (theSame(dragPoint, p, 2)) {
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        selectedPoint = p;
        repaint();
        return;
      }
    }
    selectedPoint = null;
    // If the cursor pass over a saturation sector the mouse change
    Vector<Point2D> convex = data.getResults().getAllConvex();
    for (int k = 0; k < convex.size() - 1; k++) {
      DPoint pointA = plane.getTruePoint(convex.get(k));
      DPoint pointB = plane.getTruePoint(convex.get(k + 1));

      Polygon rect = new Polygon();
      rect.addPoint((int) pointA.getX(), (int) pointA.getY() - 16);
      rect.addPoint((int) pointA.getX(), (int) pointA.getY() + 16);
      rect.addPoint((int) pointB.getX(), (int) pointB.getY() - 16);
      rect.addPoint((int) pointB.getX(), (int) pointB.getY() + 16);
      DPoint test = new DPoint(dragPoint.getX(), dragPoint.getY());
      if (rect.contains(test)) {
        selectedConvexSegment = new ConvexSegment(new DPoint(convex
            .get(k).getX(), convex.get(k).getY()), new DPoint(
            convex.get(k + 1).getX(), convex.get(k + 1).getY()));
        repaint();
        return;
      }
View Full Code Here

Examples of jmt.engine.jaba.DPoint

  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),
          1, yMaxValue);
    } catch (Exception e) {
      return;
    }

    g2.setStroke(DOTTED_LINES);
    ArrayList<DPoint> valuesOnX = new ArrayList<DPoint>();
    Vector<Object> sectors = data.getResults().getSaturationSectors();
    for (int i = 0; i < sectors.size() && sectors.size() != 1; i++) {
      FinalSect2D sect;// Current sector
      sect = (FinalSect2D) sectors.get(i);
      plane.drawProjectionOnTheXAxis(new DPoint(sect.getBeta1(),
          yMaxValue));
      valuesOnX.add(new DPoint(sect.getBeta1(), sect.getBeta11()));
    }
    g2.setStroke(LINES);

    if (!valuesOnX.contains(new DPoint(1, 0)))
      valuesOnX.add(new DPoint(1, 0));
    if (!valuesOnX.contains(new DPoint(0, 0)))
      valuesOnX.add(0, new DPoint(0, 0));
    plane.drawValuesOnXAxis(valuesOnX);

    ArrayList<DPoint>[] util;
    util = data.getResults().getUtilization();
    ArrayList<DPoint> valuesOnLeftY = new ArrayList<DPoint>();
    ArrayList<DPoint> valuesOnRightY = new ArrayList<DPoint>();
    g2.setStroke(BOLD_LINES);

    int numOfSectors = util[0].size() / 2;
    int numOfSaturatedStationPerSector[] = new int[numOfSectors];
   
    for (int j = 0; j < data.getStationNames().length; j++) {
      if (!showStation[j])
        continue;
      g.setColor(stationColors.get(j));
      int i;
      for (i = 0; i < util[j].size(); i = i + 2) {
        if (i == 0) {
          valuesOnLeftY.add(util[j].get(i));
        }
        //If the station j is saturated
        if( Math.abs(util[j].get(i).getY() - util[j].get(i + 1).getY()) < EPSILON &&
            Math.abs(util[j].get(i).getY() - 1) < EPSILON) {
          if(numOfSaturatedStationPerSector[i/2]>=1)
            g2.setStroke(DOTTED_LINES2);
          numOfSaturatedStationPerSector[i/2] = numOfSaturatedStationPerSector[i/2]+1;
        }
        plane.drawSegment(util[j].get(i), util[j].get(i + 1));
        g2.setStroke(BOLD_LINES);
      }
      i = i - 2;
      valuesOnRightY.add(util[j].get(i + 1));
    }
    // g2.setColor(Color.black);
    // plane.drawSegment(new DPoint(0, 1), new DPoint(1, 1));
    g2.setStroke(LINES);

    drawSummary(g, stationColors);

    g.setColor(Color.black);
    {// we always draw certain points
      if (!valuesOnLeftY.contains(new DPoint(0, 1)))
        valuesOnLeftY.add(new DPoint(0, 1));
      if (!valuesOnRightY.contains(new DPoint(1, 1)))
        valuesOnRightY.add(new DPoint(1, 1));
    }
    plane.drawValuesOnYAxis(valuesOnLeftY);

    {// we draw the last points in another axis
      ArrayList<String> labels;
      ArrayList<DPoint> truePoints;
      YAxisPlacer placer;
      DecimalFormat formatter = new DecimalFormat("0.000");
      labels = new ArrayList<String>();
      truePoints = new ArrayList<DPoint>();
      for (int i = 0; i < valuesOnRightY.size(); i++) {
        labels.add(formatter.format(valuesOnRightY.get(i).getY()));
        truePoints.add(plane.getTruePoint(valuesOnRightY.get(i)));
      }
      placer = new YAxisPlacer(labels, truePoints);
      placer.place((Graphics2D) g, plane.getTrueX(1) + 10);
      plane.drawSegment(new DPoint(1, 0), new DPoint(1, 1));
    }

    plane.draw("% " + data.getClassNames()[0], "Utilization");

    if (tooltip != null) {
      DPoint graphPoint = plane.getGraphPointFromTruePoint(tooltip);
      String content = FORMATTER.format(graphPoint.getX()) + ", "
          + FORMATTER.format(graphPoint.getY());
      Rectangle2D bounds = g.getFontMetrics().getStringBounds(content, g);
      g.setColor(TOOL_TIP_COLOR);
      g.fillRect((int) tooltip.getX(), (int) tooltip.getY()
          - (int) bounds.getHeight() + 1, (int) bounds.getWidth(),
          (int) bounds.getHeight() + 2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.