Java Code Examples for java.awt.RenderingHints#put()

The following examples show how to use java.awt.RenderingHints#put() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: ET_Redux   File: UncertaintyGraphPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param g2d
 */
public void paint ( Graphics2D g2d ) {

    RenderingHints rh = g2d.getRenderingHints();
    rh.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    rh.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
    g2d.setRenderingHints( rh );

    g2d.setClip( 0, 0, getWidth(), getHeight() );

    g2d.setColor( Color.BLACK );

    g2d.drawLine( MapX( 0 ), (int) mapZero, MapX( 1 ), (int) mapZero );

    // draw IUC (bars)
    int position = 0;
    int counter = 0;
    while ((position < countOfBars) && (counter < reducedZL.size())) {
        PlotIUC( g2d, reducedZL.get( counter ), position );
        position ++;
        counter ++;
    }

    infoPanel.repaint();
}
 
Example 2
@Override
public void paint(Graphics g) {
    RenderingHints renderHints =
            new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    Graphics2D Canvas = (Graphics2D) g;
    Canvas.addRenderingHints(renderHints);

    super.paint(g);
    for (IObjetoPintavel p: pintaveis) {
        p.setOutroPintor(true);
        p.DoPaint(Canvas);
        p.setOutroPintor(false);
    }
}
 
Example 3
Source Project: pumpernickel   File: TransitionDemo.java    License: MIT License 6 votes vote down vote up
public static RenderingHints createSpeedHints() {
	RenderingHints hints = new RenderingHints(
			RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_OFF);
	hints.put(RenderingHints.KEY_ALPHA_INTERPOLATION,
			RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
	hints.put(RenderingHints.KEY_COLOR_RENDERING,
			RenderingHints.VALUE_COLOR_RENDER_SPEED);
	hints.put(RenderingHints.KEY_RENDERING,
			RenderingHints.VALUE_RENDER_QUALITY);
	hints.put(RenderingHints.KEY_INTERPOLATION,
			RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
	hints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
			RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
	hints.put(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_OFF);

	return hints;
}
 
Example 4
Source Project: ET_Redux   File: ValueModelValueSlider.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param g2d
 */
public void paint(Graphics2D g2d) {

    // show all values, even zero
    RenderingHints rh = g2d.getRenderingHints();

    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2d.setRenderingHints(rh);

    g2d.setColor(Color.black);
    DrawBounds(g2d);
    g2d.setColor(Color.red);
    g2d.drawLine((width / 2), 0, (width / 2), height);

    ((ValueModelSliderBox) valueModelSliderBox).//
            setValueString(getCurrentValueShowValue());

    ((ValueModelSliderBox) valueModelSliderBox).paint(g2d);

}
 
Example 5
Source Project: ET_Redux   File: ValueModelUncertSlider.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param g2d
 */
public void paint(Graphics2D g2d) {

    // don't show missing uncts
    if (valueModelCopy.getOneSigma().compareTo(BigDecimal.ZERO) > 0) {
        RenderingHints rh = g2d.getRenderingHints();
        rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        g2d.setRenderingHints(rh);

        g2d.setColor(Color.black);
        DrawBounds(g2d);
        g2d.setColor(Color.red);
        g2d.drawLine((width / 2), 0, (width / 2), height);

        ((ValueModelSliderBox) valueModelSliderBox).//
                setValueString(getCurrentUncertaintyShowValue());

        ((ValueModelSliderBox) valueModelSliderBox).paint(g2d);

    }
}
 
Example 6
Source Project: ET_Redux   File: ValueModelClump.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param g2d
 */
public void paint ( Graphics2D g2d ) {

    RenderingHints rh = g2d.getRenderingHints();
    rh.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    rh.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
    g2d.setRenderingHints( rh );

    g2d.setColor( Color.black );
    DrawBounds( g2d );

    //  paint valuesliders
    for (Component vms : getComponents()) {
        if ( vms instanceof JPanel ) {
            vms.repaint();
        }
    }

}
 
Example 7
@Override
public RenderingHints create() {
	RenderingHints returnValue = new RenderingHints(
			new HashMap<RenderingHints.Key, Object>());
	for (Entry<String, Object> entry : map.entrySet()) {
		returnValue.put(getKey(entry.getKey()),
				getValue((String) entry.getValue()));
	}
	return returnValue;
}
 
Example 8
Source Project: sambox   File: PDFRenderer.java    License: Apache License 2.0 5 votes vote down vote up
private RenderingHints createDefaultRenderingHints(Graphics2D graphics)
{
    RenderingHints r = new RenderingHints(null);
    r.put(RenderingHints.KEY_INTERPOLATION,
            isBitonal(graphics) ? RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
                    : RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    r.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    r.put(RenderingHints.KEY_ANTIALIASING, isBitonal(graphics)
            ? RenderingHints.VALUE_ANTIALIAS_OFF : RenderingHints.VALUE_ANTIALIAS_ON);
    return r;
}
 
Example 9
Source Project: ET_Redux   File: AbstractValueModelView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param g2d
 */
protected void paintInit ( Graphics2D g2d ) {
    RenderingHints rh = g2d.getRenderingHints();
    rh.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    rh.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
    g2d.setRenderingHints( rh );

    g2d.setPaint( Color.BLACK );
    g2d.setStroke( new BasicStroke( 1.0f ) );
    g2d.setFont(ReduxConstants.sansSerif_12_Bold );

}
 
Example 10
RenderingHints makeHints(Map hints) {
    RenderingHints model = new RenderingHints(hints);
    model.put(SunHints.KEY_RENDERING,
              SunHints.Value.get(SunHints.INTKEY_RENDERING,
                                 renderHint));
    model.put(SunHints.KEY_ANTIALIASING,
              SunHints.Value.get(SunHints.INTKEY_ANTIALIASING,
                                 antialiasHint));
    model.put(SunHints.KEY_TEXT_ANTIALIASING,
              SunHints.Value.get(SunHints.INTKEY_TEXT_ANTIALIASING,
                                 textAntialiasHint));
    model.put(SunHints.KEY_FRACTIONALMETRICS,
              SunHints.Value.get(SunHints.INTKEY_FRACTIONALMETRICS,
                                 fractionalMetricsHint));
    model.put(SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST,
              Integer.valueOf(lcdTextContrast));
    Object value;
    switch (interpolationHint) {
    case SunHints.INTVAL_INTERPOLATION_NEAREST_NEIGHBOR:
        value = SunHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
        break;
    case SunHints.INTVAL_INTERPOLATION_BILINEAR:
        value = SunHints.VALUE_INTERPOLATION_BILINEAR;
        break;
    case SunHints.INTVAL_INTERPOLATION_BICUBIC:
        value = SunHints.VALUE_INTERPOLATION_BICUBIC;
        break;
    default:
        value = null;
        break;
    }
    if (value != null) {
        model.put(SunHints.KEY_INTERPOLATION, value);
    }
    model.put(SunHints.KEY_STROKE_CONTROL,
              SunHints.Value.get(SunHints.INTKEY_STROKE_CONTROL,
                                 strokeHint));
    return model;
}
 
Example 11
Source Project: ET_Redux   File: AbstractRatiosDataView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param g2d
 */
protected void paintInit(Graphics2D g2d) {
    RenderingHints rh = g2d.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2d.setRenderingHints(rh);

    g2d.setPaint(Color.BLACK);
    g2d.setStroke(new BasicStroke(1.0f));
    g2d.setFont(ReduxConstants.sansSerif_12_Bold);
}
 
Example 12
public void paintComponent(Graphics g) {
  if(OSPRuntime.antiAliasText) {
    Graphics2D g2 = (Graphics2D) g;
    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  }
  super.paintComponent(g);
}
 
Example 13
RenderingHints makeHints(Map hints) {
    RenderingHints model = new RenderingHints(hints);
    model.put(SunHints.KEY_RENDERING,
              SunHints.Value.get(SunHints.INTKEY_RENDERING,
                                 renderHint));
    model.put(SunHints.KEY_ANTIALIASING,
              SunHints.Value.get(SunHints.INTKEY_ANTIALIASING,
                                 antialiasHint));
    model.put(SunHints.KEY_TEXT_ANTIALIASING,
              SunHints.Value.get(SunHints.INTKEY_TEXT_ANTIALIASING,
                                 textAntialiasHint));
    model.put(SunHints.KEY_FRACTIONALMETRICS,
              SunHints.Value.get(SunHints.INTKEY_FRACTIONALMETRICS,
                                 fractionalMetricsHint));
    model.put(SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST,
              Integer.valueOf(lcdTextContrast));
    Object value;
    switch (interpolationHint) {
    case SunHints.INTVAL_INTERPOLATION_NEAREST_NEIGHBOR:
        value = SunHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
        break;
    case SunHints.INTVAL_INTERPOLATION_BILINEAR:
        value = SunHints.VALUE_INTERPOLATION_BILINEAR;
        break;
    case SunHints.INTVAL_INTERPOLATION_BICUBIC:
        value = SunHints.VALUE_INTERPOLATION_BICUBIC;
        break;
    default:
        value = null;
        break;
    }
    if (value != null) {
        model.put(SunHints.KEY_INTERPOLATION, value);
    }
    model.put(SunHints.KEY_STROKE_CONTROL,
              SunHints.Value.get(SunHints.INTKEY_STROKE_CONTROL,
                                 strokeHint));
    return model;
}
 
Example 14
Source Project: ET_Redux   File: HeatMapView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param g2d
 */
protected void paintInit(Graphics2D g2d) {
    RenderingHints rh = g2d.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2d.setRenderingHints(rh);

    g2d.setPaint(Color.BLACK);
    g2d.setStroke(new BasicStroke(1.0f));
    g2d.setFont(ReduxConstants.sansSerif_10_Bold);
}
 
Example 15
Source Project: osp   File: OSPLog.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates the GUI.
 */
protected void createGUI() {
  // create the panel, text pane and scroller
  logPanel = new JPanel(new BorderLayout());
  logPanel.setPreferredSize(new Dimension(480, 240));
  setContentPane(logPanel);
  textPane = new JTextPane() {
    public void paintComponent(Graphics g) {
      if(OSPRuntime.antiAliasText) {
        Graphics2D g2 = (Graphics2D) g;
        RenderingHints rh = g2.getRenderingHints();
        rh.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      }
      super.paintComponent(g);
    }

  };
  textPane.setEditable(false);
  textPane.setAutoscrolls(true);
  JScrollPane textScroller = new JScrollPane(textPane);
  textScroller.setWheelScrollingEnabled(true);
  logPanel.add(textScroller, BorderLayout.CENTER);
  // create the colored styles
  black = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
  red = textPane.addStyle("red", black); //$NON-NLS-1$
  StyleConstants.setForeground(red, DARK_RED);
  blue = textPane.addStyle("blue", black); //$NON-NLS-1$
  StyleConstants.setForeground(blue, DARK_BLUE);
  green = textPane.addStyle("green", black); //$NON-NLS-1$
  StyleConstants.setForeground(green, DARK_GREEN);
  magenta = textPane.addStyle("magenta", black); //$NON-NLS-1$
  StyleConstants.setForeground(magenta, Color.MAGENTA);
  gray = textPane.addStyle("gray", black); //$NON-NLS-1$
  StyleConstants.setForeground(gray, Color.GRAY);
  // create the logger
  createLogger();
  // create the menus
  createMenus();
  pack();
  textPane.addMouseListener(new MouseAdapter() {
    public void mousePressed(MouseEvent e) {
      try {
        if(OSPRuntime.isPopupTrigger(e)) {
          // show popup menu
          if(popup!=null) {
          	FontSizer.setFonts(popup, FontSizer.getLevel());
            popup.show(textPane, e.getX(), e.getY()+8);
          }
        }
      } catch(Exception ex) {
        System.err.println("Error in mouse action."); //$NON-NLS-1$
        System.err.println(ex.toString());
        ex.printStackTrace();
      }
    }

  });
}
 
Example 16
Source Project: scipio-erp   File: ImageTransform.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * SCIPIO: Sets given value in RenderingHints in-place; creates new if needed.
 * Added 2017-07-14.
 */
public static RenderingHints ensureRenderingHintInPlace(RenderingHints renderingHints, RenderingHints.Key key, Object value) {
    if (renderingHints == null) return new RenderingHints(key, value);
    renderingHints.put(key, value);
    return renderingHints;
}
 
Example 17
Source Project: ET_Redux   File: ValueModelSliderBox.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param g2d
 */
public void paint ( Graphics2D g2d ) {

    RenderingHints rh = g2d.getRenderingHints();
    rh.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    rh.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
    g2d.setRenderingHints( rh );

    g2d.setColor( Color.BLACK );

    // build the box to fit the value string
    TextLayout mLayout = //
            new TextLayout(
            getValueString(), valueFont, g2d.getFontRenderContext() );

    Rectangle2D bounds = mLayout.getBounds();
    setBoxWidth( (int) bounds.getWidth() + 4 );

    drawBounds( g2d );

    g2d.setFont( valueFont );

    g2d.drawString( getValueString(), getX() + 3, getY() + boxHeight - 3 );


}
 
Example 18
synchronized RenderingHints getDesktopAAHints() {

        /* Equate "DEFAULT" to "OFF", which it is in our implementation.
         * Doing this prevents unnecessary pipeline revalidation where
         * the value OFF is detected as a distinct value by SunGraphics2D
         */
        Object fontSmoothingHint = VALUE_TEXT_ANTIALIAS_DEFAULT;
        Integer fontSmoothingContrast = null;

        Boolean smoothingOn = (Boolean)map.get("win.text.fontSmoothingOn");

        if (smoothingOn != null && smoothingOn.equals(Boolean.TRUE)) {
            Integer typeID = (Integer)map.get("win.text.fontSmoothingType");
            /* "1" is GASP/Standard but we'll also use that if the return
             * value is anything other than "2" for LCD.
             */
            if (typeID == null || typeID.intValue() <= 1 ||
                typeID.intValue() > 2) {
                fontSmoothingHint = VALUE_TEXT_ANTIALIAS_GASP;
            } else {
                /* Recognise 0 as BGR and everything else as RGB - note
                 * that 1 is the expected value for RGB.
                 */
                Integer orientID = (Integer)
                    map.get("win.text.fontSmoothingOrientation");
                /* 0 is BGR, 1 is RGB. Other values, assume RGB */
                if (orientID == null || orientID.intValue() != 0) {
                    fontSmoothingHint = VALUE_TEXT_ANTIALIAS_LCD_HRGB;
                } else {
                    fontSmoothingHint = VALUE_TEXT_ANTIALIAS_LCD_HBGR;
                }

                fontSmoothingContrast = (Integer)
                    map.get("win.text.fontSmoothingContrast");
                if (fontSmoothingContrast == null) {
                    fontSmoothingContrast = Integer.valueOf(140);
                } else {
                    /* Windows values are scaled 10x those of Java 2D */
                    fontSmoothingContrast =
                        Integer.valueOf(fontSmoothingContrast.intValue()/10);
                }
            }
        }

        RenderingHints hints = new RenderingHints(null);
        hints.put(KEY_TEXT_ANTIALIASING, fontSmoothingHint);
        if (fontSmoothingContrast != null) {
            hints.put(KEY_TEXT_LCD_CONTRAST, fontSmoothingContrast);
        }
        return hints;
    }
 
Example 19
RenderingHints makeHints(Map<?,?> hints) {
    RenderingHints model = new RenderingHints(null);
    if (hints != null) {
        model.putAll(hints);
    }
    model.put(SunHints.KEY_RENDERING,
              SunHints.Value.get(SunHints.INTKEY_RENDERING,
                                 renderHint));
    model.put(SunHints.KEY_ANTIALIASING,
              SunHints.Value.get(SunHints.INTKEY_ANTIALIASING,
                                 antialiasHint));
    model.put(SunHints.KEY_TEXT_ANTIALIASING,
              SunHints.Value.get(SunHints.INTKEY_TEXT_ANTIALIASING,
                                 textAntialiasHint));
    model.put(SunHints.KEY_FRACTIONALMETRICS,
              SunHints.Value.get(SunHints.INTKEY_FRACTIONALMETRICS,
                                 fractionalMetricsHint));
    model.put(SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST,
              Integer.valueOf(lcdTextContrast));
    Object value;
    switch (interpolationHint) {
    case SunHints.INTVAL_INTERPOLATION_NEAREST_NEIGHBOR:
        value = SunHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
        break;
    case SunHints.INTVAL_INTERPOLATION_BILINEAR:
        value = SunHints.VALUE_INTERPOLATION_BILINEAR;
        break;
    case SunHints.INTVAL_INTERPOLATION_BICUBIC:
        value = SunHints.VALUE_INTERPOLATION_BICUBIC;
        break;
    default:
        value = null;
        break;
    }
    if (value != null) {
        model.put(SunHints.KEY_INTERPOLATION, value);
    }
    model.put(SunHints.KEY_STROKE_CONTROL,
              SunHints.Value.get(SunHints.INTKEY_STROKE_CONTROL,
                                 strokeHint));
    return model;
}
 
Example 20
synchronized RenderingHints getDesktopAAHints() {

        /* Equate "DEFAULT" to "OFF", which it is in our implementation.
         * Doing this prevents unnecessary pipeline revalidation where
         * the value OFF is detected as a distinct value by SunGraphics2D
         */
        Object fontSmoothingHint = VALUE_TEXT_ANTIALIAS_DEFAULT;
        Integer fontSmoothingContrast = null;

        Boolean smoothingOn = (Boolean)map.get("win.text.fontSmoothingOn");

        if (smoothingOn != null && smoothingOn.equals(Boolean.TRUE)) {
            Integer typeID = (Integer)map.get("win.text.fontSmoothingType");
            /* "1" is GASP/Standard but we'll also use that if the return
             * value is anything other than "2" for LCD.
             */
            if (typeID == null || typeID.intValue() <= 1 ||
                typeID.intValue() > 2) {
                fontSmoothingHint = VALUE_TEXT_ANTIALIAS_GASP;
            } else {
                /* Recognise 0 as BGR and everything else as RGB - note
                 * that 1 is the expected value for RGB.
                 */
                Integer orientID = (Integer)
                    map.get("win.text.fontSmoothingOrientation");
                /* 0 is BGR, 1 is RGB. Other values, assume RGB */
                if (orientID == null || orientID.intValue() != 0) {
                    fontSmoothingHint = VALUE_TEXT_ANTIALIAS_LCD_HRGB;
                } else {
                    fontSmoothingHint = VALUE_TEXT_ANTIALIAS_LCD_HBGR;
                }

                fontSmoothingContrast = (Integer)
                    map.get("win.text.fontSmoothingContrast");
                if (fontSmoothingContrast == null) {
                    fontSmoothingContrast = Integer.valueOf(140);
                } else {
                    /* Windows values are scaled 10x those of Java 2D */
                    fontSmoothingContrast =
                        Integer.valueOf(fontSmoothingContrast.intValue()/10);
                }
            }
        }

        RenderingHints hints = new RenderingHints(null);
        hints.put(KEY_TEXT_ANTIALIASING, fontSmoothingHint);
        if (fontSmoothingContrast != null) {
            hints.put(KEY_TEXT_LCD_CONTRAST, fontSmoothingContrast);
        }
        return hints;
    }