コード例 #1
0
  protected void curveVertexCheck() {
    super.curveVertexCheck();

    if (curveCoordX == null) {
      curveCoordX = new float[4];
      curveCoordY = new float[4];
      curveDrawX = new float[4];
      curveDrawY = new float[4];
    }
  }
コード例 #2
0
  /**
   * Same as parent, but override for native version of the font.
   *
   * <p>Also gets called by textFont, so the metrics will get recorded properly.
   */
  public void textSize(float size) {
    if (textFont == null) {
      defaultFontOrDeath("textAscent", size);
    }

    // if a native version available, derive this font
    //    if (textFontNative != null) {
    //      textFontNative = textFontNative.deriveFont(size);
    //      g2.setFont(textFontNative);
    //      textFontNativeMetrics = g2.getFontMetrics(textFontNative);
    //    }
    Font font = textFont.getFont();
    if (font != null && (textFont.isStream() || hints[ENABLE_NATIVE_FONTS])) {
      Font dfont = font.deriveFont(size);
      g2.setFont(dfont);
      textFont.setFont(dfont);
    }

    // take care of setting the textSize and textLeading vars
    // this has to happen second, because it calls textAscent()
    // (which requires the native font metrics to be set)
    super.textSize(size);
  }
コード例 #3
0
  protected void textLineImpl(char buffer[], int start, int stop, float x, float y) {
    Font font = textFont.getFont();
    if (font != null && (textFont.isStream() || hints[ENABLE_NATIVE_FONTS])) {
      /*
      // save the current setting for text smoothing. note that this is
      // different from the smooth() function, because the font smoothing
      // is controlled when the font is created, not now as it's drawn.
      // fixed a bug in 0116 that handled this incorrectly.
      Object textAntialias =
        g2.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);

      // override the current text smoothing setting based on the font
      // (don't change the global smoothing settings)
      g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                          textFont.smooth ?
                          RenderingHints.VALUE_ANTIALIAS_ON :
                          RenderingHints.VALUE_ANTIALIAS_OFF);
      */
      Object antialias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
      if (antialias == null) {
        // if smooth() and noSmooth() not called, this will be null (0120)
        antialias = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
      }

      // override the current smoothing setting based on the font
      // also changes global setting for antialiasing, but this is because it's
      // not possible to enable/disable them independently in some situations.
      g2.setRenderingHint(
          RenderingHints.KEY_ANTIALIASING,
          textFont.smooth ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);

      // System.out.println("setting frac metrics");
      // g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
      //                    RenderingHints.VALUE_FRACTIONALMETRICS_ON);

      g2.setColor(fillColorObject);
      int length = stop - start;
      g2.drawChars(buffer, start, length, (int) (x + 0.5f), (int) (y + 0.5f));
      // better to use drawString() with floats? (nope, draws the same)
      // g2.drawString(new String(buffer, start, length), x, y);

      // this didn't seem to help the scaling issue
      // and creates garbage because of the new temporary object
      // java.awt.font.GlyphVector gv = textFontNative.createGlyphVector(g2.getFontRenderContext(),
      // new String(buffer, start, stop));
      // g2.drawGlyphVector(gv, x, y);

      //    System.out.println("text() " + new String(buffer, start, stop));

      // return to previous smoothing state if it was changed
      // g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, textAntialias);
      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialias);

      textX = x + textWidthImpl(buffer, start, stop);
      textY = y;
      textZ = 0; // this will get set by the caller if non-zero

    } else { // otherwise just do the default
      super.textLineImpl(buffer, start, stop, x, y);
    }
  }
コード例 #4
0
 protected void fillFromCalc() {
   super.fillFromCalc();
   fillColorObject = new Color(fillColor, true);
   fillGradient = false;
 }
コード例 #5
0
 protected void tintFromCalc() {
   super.tintFromCalc();
   // TODO actually implement tinted images
   tintColorObject = new Color(tintColor, true);
 }
コード例 #6
0
 protected void strokeFromCalc() {
   super.strokeFromCalc();
   strokeColorObject = new Color(strokeColor, true);
   strokeGradient = false;
 }
コード例 #7
0
 public void strokeWeight(float weight) {
   super.strokeWeight(weight);
   strokeImpl();
 }
コード例 #8
0
 public void strokeJoin(int join) {
   super.strokeJoin(join);
   strokeImpl();
 }
コード例 #9
0
 public void strokeCap(int cap) {
   super.strokeCap(cap);
   strokeImpl();
 }