Java Code Examples for java.awt.RenderingHints#Key

The following examples show how to use java.awt.RenderingHints#Key . 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 check out the related API usage on the sidebar.
Example 1
Source File: AbstractResizer.java    From youkefu with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link AbstractResizer}.
 * 
 * @param interpolationValue		The rendering hint value to use for the
 * 									interpolation hint.
 * @param hints						Other rendering hints to add.
 */
protected AbstractResizer(
		Object interpolationValue,
		Map<RenderingHints.Key, Object> hints
)
{
	RENDERING_HINTS = new HashMap<RenderingHints.Key, Object>();
	RENDERING_HINTS.put(KEY_INTERPOLATION, interpolationValue);
	
	if (
			hints.containsKey(KEY_INTERPOLATION)
			&& !interpolationValue.equals(hints.get(KEY_INTERPOLATION))
	)
	{
		throw new IllegalArgumentException("Cannot change the " +
				"RenderingHints.KEY_INTERPOLATION value.");
	}
	
	RENDERING_HINTS.putAll(hints);
	
	UNMODIFIABLE_RENDERING_HINTS = Collections.unmodifiableMap(RENDERING_HINTS);
}
 
Example 2
Source File: MaterialDrawingUtils.java    From material-ui-swing with MIT License 6 votes vote down vote up
public static Graphics getAliasedGraphics(Graphics g) {
      Map<RenderingHints.Key, Object> hints = (Map<RenderingHints.Key, Object>) Toolkit.getDefaultToolkit ().getDesktopProperty ("awt.font.desktophints");

if(hints != null){
	hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	hints.put(RenderingHints.KEY_RENDERING,	RenderingHints.VALUE_RENDER_DEFAULT);
	hints.put(RenderingHints.KEY_COLOR_RENDERING,	RenderingHints.VALUE_COLOR_RENDER_DEFAULT);
	hints.put(RenderingHints.KEY_TEXT_ANTIALIASING,	RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

	Graphics2D g2d = (Graphics2D) g;
	g2d.addRenderingHints(hints);
	return g2d;
}

//g2d.addRenderingHints (new RenderingHints (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
return g;
  }
 
Example 3
Source File: RenderingHintsContextMenu.java    From pumpernickel with MIT License 5 votes vote down vote up
public HintInfo(RenderingHints.Key key, String keyName,
		String keyUserName) {
	super(keyUserName);
	this.key = key;
	this.keyName = keyName;
	this.keyUserName = keyUserName;
	add(undefined);
	addSeparator();
	undefined.addActionListener(actionListener);
}
 
Example 4
Source File: DummyGraphics2d.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) {
    String l =
        "setRenderingHint(RenderingHints.Key, Object):" +
        "\n  hintKey = " + hintKey +
        "\n  hintValue = " + hintValue;
    log.println( l );
    g2D.setRenderingHint( hintKey, hintValue );
}
 
Example 5
Source File: SVGIcon.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static RenderingHints createHints() {
    Map<RenderingHints.Key, Object> hints = new LinkedHashMap<RenderingHints.Key, Object>();
    hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    /* Ensure that outlined strokes (strokes converted to solid shapes) appear the same as
    regular strokes, as they do during editing in Adobe Illustrator. */
    hints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    return new RenderingHints(hints);
}
 
Example 6
Source File: HiDPIScaledGraphics.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Object getRenderingHint(RenderingHints.Key hintKey) {
  return myPeer.getRenderingHint(hintKey);
}
 
Example 7
Source File: EpsGraphics2D.java    From osp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Sets a rendering hint. These are not used by EpsGraphics2D.
 */
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) {
  // Do nothing.
}
 
Example 8
Source File: SVGHints.java    From jfreesvg with GNU General Public License v3.0 4 votes vote down vote up
private static RenderingHints.Key getJFreeChartEndElementKey() {
    return fetchKey("org.jfree.chart.ChartHints", "KEY_END_ELEMENT");
}
 
Example 9
Source File: RichGraphics2D.java    From scrimage with Apache License 2.0 4 votes vote down vote up
@Override
public Object getRenderingHint(RenderingHints.Key hintKey) {
   return g2.getRenderingHint(hintKey);
}
 
Example 10
Source File: GroupGraphics.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
{
    groupG2D.setRenderingHint(hintKey, hintValue);
    alphaG2D.setRenderingHint(hintKey, hintValue);
}
 
Example 11
Source File: FXGraphics2D.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the current value for the specified hint.  Note that all hints
 * are currently ignored in this implementation.
 * 
 * @param hintKey  the hint key ({@code null} permitted, but the
 *     result will be {@code null} also in that case).
 * 
 * @return The current value for the specified hint 
 *     (possibly {@code null}).
 * 
 * @see #setRenderingHint(java.awt.RenderingHints.Key, java.lang.Object) 
 */
@Override
public Object getRenderingHint(RenderingHints.Key hintKey) {
    return this.hints.get(hintKey);
}
 
Example 12
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the value for a hint.  Note that all hints are currently
 * ignored in this implementation.
 * 
 * @param hintKey  the hint key ({@code null} not permitted).
 * @param hintValue  the hint value.
 * 
 * @see #getRenderingHint(java.awt.RenderingHints.Key) 
 */
@Override
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) {
    this.hints.put(hintKey, hintValue);
}
 
Example 13
Source File: FXGraphics2D.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the current value for the specified hint.  Note that all hints
 * are currently ignored in this implementation.
 * 
 * @param hintKey  the hint key ({@code null} permitted, but the
 *     result will be {@code null} also in that case).
 * 
 * @return The current value for the specified hint 
 *     (possibly {@code null}).
 * 
 * @see #setRenderingHint(java.awt.RenderingHints.Key, java.lang.Object) 
 */
@Override
public Object getRenderingHint(RenderingHints.Key hintKey) {
    return this.hints.get(hintKey);
}
 
Example 14
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the current value for the specified hint.  Note that all hints
 * are currently ignored in this implementation.
 * 
 * @param hintKey  the hint key ({@code null} permitted, but the
 *     result will be {@code null} also in that case).
 * 
 * @return The current value for the specified hint 
 *     (possibly {@code null}).
 * 
 * @see #setRenderingHint(java.awt.RenderingHints.Key, java.lang.Object) 
 */
@Override
public Object getRenderingHint(RenderingHints.Key hintKey) {
    return this.hints.get(hintKey);
}
 
Example 15
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the value for a hint.  Note that all hints are currently
 * ignored in this implementation.
 * 
 * @param hintKey  the hint key ({@code null} not permitted).
 * @param hintValue  the hint value.
 * 
 * @see #getRenderingHint(java.awt.RenderingHints.Key) 
 */
@Override
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) {
    this.hints.put(hintKey, hintValue);
}
 
Example 16
Source File: SLGraphics.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the value of a single preference for the rendering algorithms.
 * Hint categories include controls for rendering quality and overall
 * time/quality trade-off in the rendering process.  Refer to the
 * <code>RenderingHints</code> class for definitions of some common
 * keys and values.
 * @param hintKey the key corresponding to the hint to get.
 * @return an object representing the value for the specified hint key.
 * Some of the keys and their associated values are defined in the
 * <code>RenderingHints</code> class.
 * @see RenderingHints
 */
public Object getRenderingHint(RenderingHints.Key hintKey){
    return _hints.get(hintKey);
}
 
Example 17
Source File: AbstractResizer.java    From youkefu with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the rendering hints that the resizer uses.
 * <p>
 * The keys and values used for the rendering hints are those defined in
 * the {@link RenderingHints} class.
 * 
 * @see RenderingHints
 * @return		Rendering hints used when resizing the image.
 */
public Map<RenderingHints.Key, Object> getRenderingHints()
{
	return UNMODIFIABLE_RENDERING_HINTS;
}
 
Example 18
Source File: SVGHints.java    From jfreesvg with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates and returns a list of keys that are synonymous with 
 * {@link #KEY_END_GROUP}.
 * 
 * @return A list (never {@code null}).
 * 
 * @since 1.8
 */
public static List<RenderingHints.Key> getEndGroupKeys() {
    return new ArrayList<>(endGroupKeys);    
}
 
Example 19
Source File: AbstractGraphics2D.java    From pentaho-reporting with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Sets the value of a single preference for the rendering algorithms. Hint categories include controls for rendering
 * quality and overall time/quality trade-off in the rendering process. Refer to the <code>RenderingHints</code> class
 * for definitions of some common keys and values.
 *
 * @param hintKey
 *          the key of the hint to be set.
 * @param hintValue
 *          the value indicating preferences for the specified hint category.
 * @see #getRenderingHint(java.awt.RenderingHints.Key)
 * @see java.awt.RenderingHints
 */
public void setRenderingHint( final RenderingHints.Key hintKey, final Object hintValue ) {
  dg2.setRenderingHint( hintKey, hintValue );
}
 
Example 20
Source File: SVGHints.java    From jfreesvg with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds a key to the list of keys that are synonyms for 
 * {@link SVGHints#KEY_ELEMENT_TITLE}.
 * 
 * @param key  the key ({@code null} not permitted).
 * 
 * @since 1.9
 */
public static void addElementTitleKey(RenderingHints.Key key) {
    elementTitleKeys.add(key);
}