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

The following are Jave code examples for showing how to use put() of the java.awt.RenderingHints class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: brModelo   File: MasterCli.java   Source Code and License Vote up 6 votes
@Override
public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;
    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    g2d.addRenderingHints(renderHints);

    g2d.setPaint(Color.BLACK);
    Stroke stroke = new BasicStroke(2.f,
            BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
    g2d.setStroke(stroke);

    PintarTextos(g2d);
}
 
Example 2
Project: brModelo   File: Editor.java   Source Code and License Vote up 6 votes
@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g); //paint background

    if (diagramaAtual == null) {
        return;
    }

    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);

    Canvas.setPaint(Color.BLACK);
    Stroke stroke = new BasicStroke(2.f,
            BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
    Canvas.setStroke(stroke);

    Canvas.drawRect(box.getLocation().x, box.getLocation().y, box.getWidth(), box.getHeight());
    Canvas.setPaint(Color.GRAY);
    Canvas.drawRect(box.getLocation().x + 1, box.getLocation().y + 1, box.getWidth(), box.getHeight());
    //Canvas.setPaint(Color.BLACK);
}
 
Example 3
Project: brModelo   File: PainelPintador.java   Source Code and License Vote up 6 votes
@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 4
Project: brModelo   File: InspectorItemBase.java   Source Code and License Vote up 6 votes
@Override
public void paint(Graphics g) {
    super.paint(g);
    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    Graphics2D Canvas = (Graphics2D) g;

    Canvas.addRenderingHints(renderHints);

    Canvas.setStroke(new BasicStroke(
            1f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND));

    Canvas.setPaint(Color.BLACK);

    paint2D(Canvas);
}
 
Example 5
Project: COE1186   File: TimerBasedAnimation.java   Source Code and License Vote up 6 votes
public void paint(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2 = (Graphics2D) g;

  RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
      RenderingHints.VALUE_ANTIALIAS_ON);

  rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

  g2.setRenderingHints(rh);
  Dimension size = getSize();

  if (initialize) {
    reset(size.width, size.height);
    initialize = false;
  }
  this.step(size.width, size.height);
  render(size.width, size.height, g2);
}
 
Example 6
Project: incubator-netbeans   File: Utils.java   Source Code and License Vote up 5 votes
public static RenderingHints checkedRenderingHints(RenderingHints rHints) {
    if (!forceSpeed) return rHints;
    RenderingHints hints = (RenderingHints)rHints.clone();
    hints.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
    hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    hints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
    hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    hints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
    hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    return hints;
}
 
Example 7
Project: OpenJSharp   File: SunGraphics2D.java   Source Code and License Vote up 5 votes
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 8
Project: jdk8u-jdk   File: SunGraphics2D.java   Source Code and License Vote up 5 votes
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 9
Project: brModelo   File: Diagrama.java   Source Code and License Vote up 5 votes
public void ExternalPaint(Graphics g) {
    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    Graphics2D Canvas = (Graphics2D) g;

    Canvas.addRenderingHints(renderHints);

    Canvas.setStroke(new BasicStroke(
            1f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND));

    Canvas.setPaint(Color.BLACK);

    for (int i = subItens.size() - 1; i > -1; i--) {
        Elementar e = subItens.get(i);
        if (e.CanPaint()) {
            e.DoPaint(Canvas);
        }
    }
}
 
Example 10
Project: brModelo   File: Diagrama.java   Source Code and License Vote up 5 votes
public void ExternalPaintSelecao(Graphics g) {
    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    Graphics2D Canvas = (Graphics2D) g;

    Canvas.addRenderingHints(renderHints);

    Canvas.setStroke(new BasicStroke(
            1f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND));

    Canvas.setPaint(Color.BLACK);

    for (int i = getItensSelecionados().size() - 1; i > -1; i--) {
        FormaElementar e = getItensSelecionados().get(i);
        e.HidePontos(true);
        if (e.CanPaint()) {
            e.DoPaint(Canvas);
        }
        e.HidePontos(false);
    }
}
 
Example 11
Project: brModelo   File: JListItemParaItemLegenda.java   Source Code and License Vote up 5 votes
@Override
public Component getListCellRendererComponent(JList list, Object value,
        int index, boolean isSelected, boolean cellHasFocus) {
    Legenda.ItemDeLegenda entry = (Legenda.ItemDeLegenda) value;
    setText(entry.getTexto());

    BufferedImage off_Image = new BufferedImage(ehLina ? 32 : 16, 16, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g = off_Image.createGraphics();
    
    RenderingHints renderHints =
            new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    
    g.addRenderingHints(renderHints);
    g.setColor(entry.getCor());
    if (ehLina) {
        g.fillRect(1, 6, 30, 4);
    } else {
        g.fillRect(1, 1, 14, 14);
    }
    ImageIcon img = new ImageIcon(off_Image);

    setIcon(img);

    if (isSelected) {
        setBackground(HIGHLIGHT_COLOR);
        setForeground(Color.white);
    } else {
        setBackground(Color.white);
        setForeground(Color.black);
    }
    
    return this;
}
 
Example 12
Project: brModelo   File: QuadroDeEdicao.java   Source Code and License Vote up 5 votes
@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g); //paint background
    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    //renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
    Graphics2D Canvas = (Graphics2D) g;

    Canvas.addRenderingHints(renderHints);

    Canvas.setStroke(new BasicStroke(
            1f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND));

    Canvas.setPaint(Color.BLACK);
    ProcessPaint(Canvas);
}
 
Example 13
Project: brModelo   File: Desenhador.java   Source Code and License Vote up 5 votes
private void drawArrow(Graphics2D g, int x1, int y1, int x2, int y2) {

        RenderingHints renderHints
                = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
        renderHints.put(RenderingHints.KEY_RENDERING,
                RenderingHints.VALUE_RENDER_QUALITY);

        renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        g.addRenderingHints(renderHints);

        g.setStroke(new BasicStroke(
                getSetaLargura(),
                BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND));

        //g.setPaint(Color.BLACK);
        int ARR_SIZE = 3 + getSetaLargura();
        double dx = x2 - x1, dy = y2 - y1;
        double angle = Math.atan2(dy, dx);
        int len = (int) Math.sqrt(dx * dx + dy * dy);
        AffineTransform at = AffineTransform.getTranslateInstance(x1, y1);
        at.concatenate(AffineTransform.getRotateInstance(angle));
        //AffineTransform bkp = g.getTransform();
        g.setTransform(at);

        // Draw horizontal arrow starting in (0, 0)
        g.drawLine(ARR_SIZE, 0, len - ARR_SIZE, 0);

        if (isSetaPontaEsquerda()) {
            g.fillPolygon(new int[]{len, len - ARR_SIZE, len - ARR_SIZE, len},
                    new int[]{0, -ARR_SIZE, ARR_SIZE, 0}, 4);
        }
        if (isSetaPontaDireita()) {
            g.fillPolygon(new int[]{0, ARR_SIZE, ARR_SIZE, 0},
                    new int[]{0, -ARR_SIZE, ARR_SIZE, 0}, 4);
        }
    }
 
Example 14
Project: incubator-netbeans   File: ChartComponent.java   Source Code and License Vote up 4 votes
private void initRenderingHints() {
    RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    setRenderingHints(hints);
}
 
Example 15
Project: OpenDA   File: PlotBox.java   Source Code and License Vote up 4 votes
private RenderingHints _defaultImageRenderingHints() {
    RenderingHints hints = new RenderingHints(null);
    hints.put(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    return hints;
}
 
Example 16
Project: OpenJSharp   File: WDesktopProperties.java   Source Code and License Vote up 4 votes
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 17
Project: jdk8u-jdk   File: WDesktopProperties.java   Source Code and License Vote up 4 votes
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 18
Project: openjdk-jdk10   File: SunGraphics2D.java   Source Code and License Vote up 4 votes
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 19
Project: openjdk-jdk10   File: WDesktopProperties.java   Source Code and License Vote up 4 votes
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 20
Project: brModelo   File: ImpressorPreview.java   Source Code and License Vote up 4 votes
@Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g); //paint background
        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);

//        Canvas.setPaint(Color.BLACK);
//        Canvas.draw3DRect(0, 0, getWidth() - 4, getHeight() - 4, true);
        Canvas.setPaint(Color.BLACK);
        Stroke stroke = new BasicStroke(1.f,
                BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
        Canvas.setStroke(stroke);

        Canvas.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
        Canvas.setPaint(Color.GRAY);
        Canvas.drawRect(0, 0, getWidth() - 2, getHeight() - 2);

        if (pgatual == 0) {
            return;
        }
        float[] dash4 = {2f, 2f, 2f};

        BasicStroke bs4 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash4,
                2f);
        Canvas.setStroke(bs4);

        Canvas.drawLine(l - 1, 1, l - 1, getHeight() - 1);
        Canvas.drawLine(l + w + 1, 1, l + w + 1, getHeight() - 1);
        Canvas.drawLine(1, t - 1, getWidth() - 1, t - 1);
        Canvas.drawLine(1, t + h + 1, getWidth() - 1, t + h + 1);

        Canvas.setStroke(new BasicStroke(
                1f,
                BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND));
        Canvas.setPaint(Color.BLACK);
        DrawPagina(Canvas);
    }