private static Map installDesktopHints(Graphics2D g2) /* 72: */ { /* 73:149 */ Map oldRenderingHints = null; /* 74:150 */ if (LookUtils.IS_JAVA_6_OR_LATER) /* 75: */ { /* 76:151 */ Map desktopHints = desktopHints(g2); /* 77:152 */ if ((desktopHints != null) && (!desktopHints.isEmpty())) /* 78: */ { /* 79:153 */ oldRenderingHints = new HashMap(desktopHints.size()); /* 80:155 */ for (Iterator i = desktopHints.keySet().iterator(); i.hasNext();) /* 81: */ { /* 82:156 */ RenderingHints.Key key = (RenderingHints.Key)i.next(); /* 83:157 */ oldRenderingHints.put(key, g2.getRenderingHint(key)); /* 84: */ } /* 85:159 */ g2.addRenderingHints(desktopHints); /* 86: */ } /* 87: */ } /* 88:162 */ return oldRenderingHints; /* 89: */ }
private JMenu buildMenuCheckBoxes(JMenu root, Key key, Object[] values) { ButtonGroup group = new ButtonGroup(); JCheckBoxMenuItem item = null; for(int i = 0; i < values.length; i++) { item = new JCheckBoxMenuItem(values[i].toString()); group.add(item); item.addItemListener(new MenuItemListener(key, values[i])); root.add(item); if (item.getText().matches(".*default.*|.*Default.*|.*DEFAULT.*")) item.setSelected(true); } return root; }
public static BufferedImage shrink(InputStream is, int maxWidth, int maxHeight, Map<Key, Object> hints) throws IOException { BufferedImage image; try { image = ImageIO.read(is); } catch (IOException e) { throw e; } double scale = calcScale(image.getWidth(), image.getHeight(), maxWidth, maxHeight); if (1.0 <= scale) { // FIXME } BufferedImage shrinkImage = resize(image, scale, hints); return shrinkImage; }
void referencingFactoryContainer() { Object datumFactory = null; Object csFactory = null; Object crsFactory = null; Object mtFactory = null; // referencingFactoryContainer start Map<Key, Object> map = new HashMap<Key, Object>(); map.put(Hints.DATUM_FACTORY, datumFactory); map.put(Hints.CS_FACTORY, csFactory); map.put(Hints.CRS_FACTORY, crsFactory); map.put(Hints.MATH_TRANSFORM_FACTORY, mtFactory); Hints hints = new Hints(map); ReferencingFactoryContainer container = new ReferencingFactoryContainer(hints); // referencingFactoryContainer end }
private static Map installDesktopHints(Graphics2D g2) { Map oldRenderingHints = null; if (LookUtils.IS_JAVA_6_OR_LATER) { Map desktopHints = desktopHints(g2); if ((desktopHints != null) && (!desktopHints.isEmpty())) { oldRenderingHints = new HashMap(desktopHints.size()); for (Iterator i = desktopHints.keySet().iterator(); i.hasNext(); ) { RenderingHints.Key key = (RenderingHints.Key)i.next(); oldRenderingHints.put(key, g2.getRenderingHint(key)); } g2.addRenderingHints(desktopHints); } } return oldRenderingHints; }
/** * Sets the preferences for the rendering algorithms. * Hint categories include controls for rendering quality and * overall time/quality trade-off in the rendering process. * @param hints The rendering hints to be set * @see RenderingHints */ public void setRenderingHints(Map<?,?> hints) { this.hints = null; renderHint = SunHints.INTVAL_RENDER_DEFAULT; antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF; textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT; fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF; lcdTextContrast = lcdTextContrastDefaultValue; interpolationHint = -1; interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR; boolean customHintPresent = false; Iterator<?> iter = hints.keySet().iterator(); while (iter.hasNext()) { Object key = iter.next(); if (key == SunHints.KEY_RENDERING || key == SunHints.KEY_ANTIALIASING || key == SunHints.KEY_TEXT_ANTIALIASING || key == SunHints.KEY_FRACTIONALMETRICS || key == SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST || key == SunHints.KEY_STROKE_CONTROL || key == SunHints.KEY_INTERPOLATION) { setRenderingHint((Key) key, hints.get(key)); } else { customHintPresent = true; } } if (customHintPresent) { this.hints = makeHints(hints); } invalidatePipe(); }
/** * Adds a number of preferences for the rendering algorithms. * Hint categories include controls for rendering quality and * overall time/quality trade-off in the rendering process. * @param hints The rendering hints to be set * @see RenderingHints */ public void addRenderingHints(Map<?,?> hints) { boolean customHintPresent = false; Iterator<?> iter = hints.keySet().iterator(); while (iter.hasNext()) { Object key = iter.next(); if (key == SunHints.KEY_RENDERING || key == SunHints.KEY_ANTIALIASING || key == SunHints.KEY_TEXT_ANTIALIASING || key == SunHints.KEY_FRACTIONALMETRICS || key == SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST || key == SunHints.KEY_STROKE_CONTROL || key == SunHints.KEY_INTERPOLATION) { setRenderingHint((Key) key, hints.get(key)); } else { customHintPresent = true; } } if (customHintPresent) { if (this.hints == null) { this.hints = makeHints(hints); } else { this.hints.putAll(hints); } } }
/** * Sets a rendering hint * @param arg0 * @param arg1 */ public void setRenderingHint(Key arg0, Object arg1) { if (arg1 != null) { rhints.put(arg0, arg1); } else { if (arg0 instanceof HyperLinkKey) { rhints.put(arg0, HyperLinkKey.VALUE_HYPERLINKKEY_OFF); } else { rhints.remove(arg0); } } }
/** * Instantiates the {@code NullResizer} which draws the source image at * the origin of the destination image. */ public NullResizer() { this( RenderingHints.VALUE_INTERPOLATION_BILINEAR, Collections.<Key, Object>emptyMap() ); }
@Override public void setRenderingHint(Key hintKey, Object hintValue) { if(hintValue==null) { hints.remove(hintKey); } else { hints.put(hintKey, hintValue); } }
public Object getRenderingHint(Key hintKey) { if(output) { System.out.println(i()+"getRenderingHint( "+hintKey+" )"); } indent++; try { Object returnValue = g.getRenderingHint(hintKey); System.out.println(i()+" = "+returnValue); return returnValue; } finally { indent--; } }
public void setRenderingHint(Key hintKey, Object hintValue) { if(output) { System.out.println(i()+"setRenderingHint( "+hintKey+", "+hintValue+" )"); } indent++; try { g.setRenderingHint(hintKey, hintValue); } finally { indent--; } }
@Override public void setRenderingHints(final Map<?, ?> hints) { renderingHint.clear(); final Iterator it = hints.keySet().iterator(); while(it.hasNext()){ final Object key = it.next(); if(key instanceof Key){ renderingHint.put(key, hints.get(key)); } } }
@Override public void addRenderingHints(final Map<?, ?> hints) { final Iterator it = hints.keySet().iterator(); while(it.hasNext()){ final Object key = it.next(); if(key instanceof Key){ renderingHint.put(key, hints.get(key)); } } }
public void paintIcon(Component c, Graphics g, int x, int y) /* 60: */ { /* 61:103 */ JCheckBox cb = (JCheckBox)c; /* 62:104 */ ButtonModel model = cb.getModel(); /* 63:105 */ Graphics2D g2 = (Graphics2D)g; /* 64:106 */ boolean paintFocus = ((model.isArmed()) && (!model.isPressed())) || ((cb.hasFocus()) && (PlasticXPIconFactory.isBlank(cb.getText()))); /* 65: */ /* 66: */ /* 67:109 */ RenderingHints.Key key = RenderingHints.KEY_ANTIALIASING; /* 68:110 */ Object newAAHint = RenderingHints.VALUE_ANTIALIAS_ON; /* 69:111 */ Object oldAAHint = g2.getRenderingHint(key); /* 70:112 */ if (newAAHint != oldAAHint) { /* 71:113 */ g2.setRenderingHint(key, newAAHint); /* 72: */ } else { /* 73:115 */ oldAAHint = null; /* 74: */ } /* 75:118 */ drawBorder(g2, model.isEnabled(), x, y, SIZE - 1, SIZE - 1); /* 76:119 */ drawFill(g2, model.isPressed(), x + 1, y + 1, SIZE - 2, SIZE - 2); /* 77:120 */ if (paintFocus) { /* 78:121 */ drawFocus(g2, x + 1, y + 1, SIZE - 3, SIZE - 3); /* 79: */ } /* 80:123 */ if (model.isSelected()) { /* 81:124 */ drawCheck(g2, model.isEnabled(), x + 3, y + 3, SIZE - 7, SIZE - 7); /* 82: */ } /* 83:127 */ if (oldAAHint != null) { /* 84:128 */ g2.setRenderingHint(key, oldAAHint); /* 85: */ } /* 86: */ }
public void paintIcon(Component c, Graphics g, int x, int y) /* 164: */ { /* 165:198 */ Graphics2D g2 = (Graphics2D)g; /* 166:199 */ AbstractButton rb = (AbstractButton)c; /* 167:200 */ ButtonModel model = rb.getModel(); /* 168:201 */ boolean paintFocus = ((model.isArmed()) && (!model.isPressed())) || ((rb.hasFocus()) && (PlasticXPIconFactory.isBlank(rb.getText()))); /* 169: */ /* 170: */ /* 171:204 */ RenderingHints.Key key = RenderingHints.KEY_ANTIALIASING; /* 172:205 */ Object newAAHint = RenderingHints.VALUE_ANTIALIAS_ON; /* 173:206 */ Object oldAAHint = g2.getRenderingHint(key); /* 174:207 */ if (newAAHint != oldAAHint) { /* 175:208 */ g2.setRenderingHint(key, newAAHint); /* 176: */ } else { /* 177:210 */ oldAAHint = null; /* 178: */ } /* 179:213 */ drawFill(g2, model.isPressed(), x, y, SIZE - 1, SIZE - 1); /* 180:214 */ if (paintFocus) { /* 181:215 */ drawFocus(g2, x + 1, y + 1, SIZE - 3, SIZE - 3); /* 182: */ } /* 183:217 */ if (model.isSelected()) { /* 184:218 */ drawCheck(g2, c, model.isEnabled(), x + 4, y + 4, SIZE - 8, SIZE - 8); /* 185: */ } /* 186:220 */ drawBorder(g2, model.isEnabled(), x, y, SIZE - 1, SIZE - 1); /* 187:222 */ if (oldAAHint != null) { /* 188:223 */ g2.setRenderingHint(key, oldAAHint); /* 189: */ } /* 190: */ }
@Override public void handleRenderingHint(Key key, Object value) { if (value != null) model.addRenderingHint(key, value); else model.removeRenderingHint(key); }
@Override public void setRenderingHint(final Key hintKey, final Object hintValue) { toBeDrawn.add(new Drawable() { public void draw(Graphics2D g) { g.setRenderingHint(hintKey, hintValue); } }); }
@Override public void setRenderingHint(Key arg0, Object arg1) { StaticCallDefinition call = new StaticCallDefinition(21,2); call.addValue(arg0); call.addValue(arg1); stack.add(call); }
public static byte[] shrinkAsByteArray(InputStream is, String formatName, int maxWidth, int maxHeight, Map<Key, Object> hints) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { BufferedOutputStream bos = new BufferedOutputStream(baos); try { shrink(is, bos, formatName, maxWidth, maxHeight, hints); bos.flush(); return baos.toByteArray(); } finally { bos.close(); } } finally { baos.close(); } }
private void processSvg(Collection<Image> images, OutputStream stream, DrawLayout layout) throws OutputException { DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); // Create an instance of org.w3c.dom.Document. String svgNS = "http://www.w3.org/2000/svg"; Document document = domImpl.createDocument(svgNS, "svg", null); SVGGeneratorContext context = SVGGeneratorContext.createDefault(document); context.setGraphicContextDefaults(new SVGGeneratorContext.GraphicContextDefaults()); // set default font context.getGraphicContextDefaults().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); // set antialiasing Map<Key, Object> map = new HashMap<>(); map.put(RenderingHints.KEY_ANTIALIASING, Boolean.TRUE); map.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); context.getGraphicContextDefaults().setRenderingHints(new RenderingHints(map)); SVGGraphics2D g2d = new SVGGraphics2D(context, false); List<Dimension> sizes = this.getSizes(images, g2d); Dimension size = this.getTotalSize(sizes, layout); g2d.setSVGCanvasSize(size); this.drawImages(sizes, images, g2d, layout); // write to ouput - do not use css style boolean useCSS = false; try { Writer out = new OutputStreamWriter(stream, "UTF-8"); g2d.stream(out, useCSS); } catch (IOException e) { throw new OutputException(e.getMessage(), e); } }
@Override public void addRenderingHints(Map<?, ?> hints) { if (isDisposed()) { return; } for (Entry<?, ?> entry : hints.entrySet()) { setRenderingHint((Key) entry.getKey(), entry.getValue()); } }
@Override public Object getRenderingHint(Key hintKey) { if (RenderingHints.KEY_ANTIALIASING.equals(hintKey)) { return RenderingHints.VALUE_ANTIALIAS_OFF; } else if (RenderingHints.KEY_TEXT_ANTIALIASING.equals(hintKey)) { return RenderingHints.VALUE_TEXT_ANTIALIAS_OFF; } else if (RenderingHints.KEY_FRACTIONALMETRICS.equals(hintKey)) { return RenderingHints.VALUE_FRACTIONALMETRICS_ON; } return state.getHints().get(hintKey); }
@Override public void setRenderingHint(Key hintKey, Object hintValue) { if (isDisposed()) { return; } state.getHints().put(hintKey, hintValue); emit(new SetHintCommand(hintKey, hintValue)); }
@Override public void setRenderingHints(Map<?, ?> hints) { if (isDisposed()) { return; } state.getHints().clear(); for (Entry<?, ?> hint : hints.entrySet()) { setRenderingHint((Key) hint.getKey(), hint.getValue()); } }