Java Graphics Settings getRenderingHints(final Graphics2D g2d, final Map hintsToSave, Map savedHints)

Here you can find the source of getRenderingHints(final Graphics2D g2d, final Map hintsToSave, Map savedHints)

Description

Returns map with rendering hints from a Graphics instance.

License

Open Source License

Parameter

Parameter Description
g2d Graphics instance
hintsToSave map of RenderingHint key-values
savedHints map to save hints into

Return

map with rendering hints from a Graphics instance

Declaration

private static Map getRenderingHints(final Graphics2D g2d, final Map hintsToSave, Map savedHints) 

Method Source Code

//package com.java2s;
/*/*from w  w w  .j av  a  2 s  .c  om*/
 * This file is part of WebLookAndFeel library.
 *
 * WebLookAndFeel library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WebLookAndFeel library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WebLookAndFeel library.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.*;

import java.util.*;

public class Main {
    /**
     * Returns map with rendering hints from a Graphics instance.
     *
     * @param g2d         Graphics instance
     * @param hintsToSave map of RenderingHint key-values
     * @param savedHints  map to save hints into
     * @return map with rendering hints from a Graphics instance
     */
    private static Map getRenderingHints(final Graphics2D g2d, final Map hintsToSave, Map savedHints) {
        if (savedHints == null) {
            savedHints = new RenderingHints(null);
        } else {
            savedHints.clear();
        }
        if (hintsToSave == null || hintsToSave.size() == 0) {
            return savedHints;
        }
        final Set objects = hintsToSave.keySet();
        for (final Object o : objects) {
            final RenderingHints.Key key = (RenderingHints.Key) o;
            final Object value = g2d.getRenderingHint(key);
            if (value != null) {
                savedHints.put(key, value);
            }
        }
        return savedHints;
    }

    /**
     * Returns component size represented as a rectangle with zero X and Y coordinates.
     *
     * @param component component to process
     * @return component size rectangle
     */
    public static Rectangle size(final Component component) {
        return new Rectangle(0, 0, component.getWidth(), component.getHeight());
    }
}

Related

  1. getDefaultConfiguration()
  2. getDefaultGraphicsConfiguration()
  3. getDefaultGraphicsConfiguration()
  4. getDefaultGraphicsConfiguration()
  5. getMaxWindowBounds(final GraphicsConfiguration gc, final boolean applyScreenInsets)
  6. getRenderingHints(Graphics2D g2d, Map hintsToSave, RenderingHints savedHints)
  7. getRenderingHints(Graphics2D g2d, RenderingHints hintsToSave, RenderingHints savedHints)
  8. getSecondWindowConfiguration()
  9. getTransparentGraphicsConfiguration()