예제 #1
0
  /*
   * (non-Javadoc)
   *
   * @see org.math.plot.render.AbstractDrawer#fillPloygon(double[][])
   */
  public void fillPolygon(float alpha, double[]... pC) {
    int[][] c = new int[pC.length][2];
    for (int i = 0; i < pC.length; i++) {
      c[i] = projection.screenProjection(pC[i]);
    }

    int minx = c[0][0], miny = c[0][1], maxx = c[0][0] + 1, maxy = c[0][1] + 1;
    int[] x = new int[c.length];
    for (int i = 0; i < c.length; i++) {
      x[i] = c[i][0];
      minx = FastMath.min(minx, x[i]);
      maxx = FastMath.max(maxx, x[i]);
    }
    int[] y = new int[c.length];
    for (int i = 0; i < c.length; i++) {
      y[i] = c[i][1];
      miny = FastMath.min(miny, y[i]);
      maxy = FastMath.max(maxy, y[i]);
    }
    if (comp2D.hitClip(minx, miny, maxx - minx, maxy - miny)) {
      Composite cs = comp2D.getComposite();
      comp2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
      comp2D.fillPolygon(x, y, c.length);
      comp2D.setComposite(cs);
    }
  }
예제 #2
0
  /*
   * (non-Javadoc)
   *
   * @see org.math.plot.render.AbstractDrawer#drawStringRatio(java.lang.String,
   *      double[], double, double, double)
   */
  public void drawTextBase(String label, double... rC) {
    int[] sC = projection.screenProjectionBase(rC);

    // Corner offset adjustment : Text Offset is used Here
    FontRenderContext frc = comp2D.getFontRenderContext();
    Font font1 = comp2D.getFont();
    int x = sC[0];
    int y = sC[1];
    double w = font1.getStringBounds(label, frc).getWidth();
    double h = font1.getSize2D();
    x -= (int) (w * text_Eastoffset);
    y += (int) (h * text_Northoffset);

    int wc = (int) (w * FastMath.cos(text_angle) + h * FastMath.sin(text_angle));
    int hc = (int) (h * FastMath.cos(text_angle) + w * FastMath.sin(text_angle));
    if (!comp2D.hitClip(x, y, wc, hc)) {
      return;
    }

    if (text_angle != 0) {
      comp2D.rotate(text_angle, x + w / 2, y - h / 2);
    }

    String[] lines = label.split("\n");
    for (int i = 0; i < lines.length; i++) {
      comp2D.drawString(lines[i], x, y);
      y += h;
    }
    // comp2D.drawString(label, x, y);

    if (text_angle != 0) {
      comp2D.rotate(-text_angle, x + w / 2, y - h / 2);
    }
  }
예제 #3
0
 public void drawPatternDot(double... pC) {
   int[] sC = projection.screenProjection(pC);
   int yoffset = (int) FastMath.ceil(dot_pattern.length / 2.0);
   int xoffset = (int) FastMath.ceil(dot_pattern[0].length / 2.0);
   for (int i = 0; i < dot_pattern.length; i++) {
     for (int j = 0; j < dot_pattern[i].length; j++) {
       if (dot_pattern[i][j]) // comp2D.setColor(new Color(getColor())
       {
         // System.err.println("comp2D.fillRect");
         comp2D.fillRect(sC[0] - xoffset + j, sC[1] - yoffset + i, 1, 1);
       }
     }
   }
 }
예제 #4
0
  public void drawShadowedText(String label, float alpha, double... pC) {
    int[] sC = projection.screenProjection(pC);

    // Corner offset adjustment : Text Offset is used Here
    FontRenderContext frc = comp2D.getFontRenderContext();
    Font font1 = comp2D.getFont();
    int x = sC[0];
    int y = sC[1];
    double w = font1.getStringBounds(label, frc).getWidth();
    double h = font1.getSize2D();
    x -= (int) (w * text_Eastoffset);
    y += (int) (h * text_Northoffset);

    int wc = (int) (w * FastMath.cos(text_angle) + h * FastMath.sin(text_angle));
    int hc = (int) (h * FastMath.cos(text_angle) + w * FastMath.sin(text_angle));
    if (!comp2D.hitClip(x, y, wc, hc)) {
      return;
    }

    if (text_angle != 0) {
      comp2D.rotate(text_angle, x + w / 2, y - h / 2);
    }

    Composite cs = comp2D.getComposite();
    Color c = comp2D.getColor();

    String[] lines = label.split("\n");
    for (int i = 0; i < lines.length; i++) {

      comp2D.setColor(Color.white);
      comp2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
      comp2D.fillRect(x, y - (int) h, (int) w, (int) h);
      comp2D.setComposite(cs);
      comp2D.setColor(c);

      comp2D.drawString(lines[i], x, y);
      y += h;
    }

    if (text_angle != 0) {
      comp2D.rotate(-text_angle, x + w / 2, y - h / 2);
    }
  }
예제 #5
0
  /*
   * (non-Javadoc)
   *
   * @see org.math.plot.render.AbstractDrawer#drawPloygon(double[][])
   */
  public void drawPolygon(double[]... pC) {
    int[][] c = new int[pC.length][2];
    for (int i = 0; i < pC.length; i++) {
      c[i] = projection.screenProjection(pC[i]);
    }

    int minx = c[0][0], miny = c[0][1], maxx = c[0][0] + 1, maxy = c[0][1] + 1;
    int[] x = new int[c.length];
    for (int i = 0; i < c.length; i++) {
      x[i] = c[i][0];
      minx = FastMath.min(minx, x[i]);
      maxx = FastMath.max(maxx, x[i]);
    }
    int[] y = new int[c.length];
    for (int i = 0; i < c.length; i++) {
      y[i] = c[i][1];
      miny = FastMath.min(miny, y[i]);
      maxy = FastMath.max(maxy, y[i]);
    }

    if (comp2D.hitClip(minx, miny, maxx - minx, maxy - miny)) {
      comp2D.drawPolygon(x, y, c.length);
    }
  }
예제 #6
0
  private void drawLine(int[]... c) {
    int minx = c[0][0], miny = c[0][1], maxx = c[0][0] + 1, maxy = c[0][1] + 1;
    int[] x = new int[c.length];
    for (int i = 0; i < c.length; i++) {
      x[i] = c[i][0];
      minx = FastMath.min(minx, x[i]);
      maxx = FastMath.max(maxx, x[i]);
    }
    int[] y = new int[c.length];
    for (int i = 0; i < c.length; i++) {
      y[i] = c[i][1];
      miny = FastMath.min(miny, y[i]);
      maxy = FastMath.max(maxy, y[i]);
    }

    if (comp2D.hitClip(minx, miny, maxx - minx, maxy - miny)) {
      Stroke s = null;
      switch (line_type) {
        case CONTINOUS_LINE:
          s = new BasicStroke(line_width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
          break;
        case DOTTED_LINE:
          s =
              new BasicStroke(
                  line_width,
                  BasicStroke.CAP_BUTT,
                  BasicStroke.JOIN_ROUND,
                  1f,
                  new float[] {2f},
                  0f);
          break;
      }
      comp2D.setStroke(s);
      comp2D.drawPolyline(x, y, c.length);
    }
  }