X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Futils%2FQualityHints.java;h=6522bfefbe9e17808df469317d5f3981108f81eb;hb=452670c58399d8054872655841ebb6e66d9c6b6e;hp=3db475e0ddb86f8340eba94190fa58f2220a0a8c;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/QualityHints.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/QualityHints.java index 3db475e0d..6522bfefb 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/QualityHints.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/QualityHints.java @@ -1,85 +1,85 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.scenegraph.utils; - -import java.awt.Graphics2D; -import java.awt.RenderingHints; - -/** - * Rendering quality hints - * - * @author Toni Kalajainen - */ -public class QualityHints { - - public static final QualityHints HIGH_QUALITY_HINTS = - new QualityHints(RenderingHints.VALUE_RENDER_QUALITY, - RenderingHints.VALUE_ANTIALIAS_ON, - RenderingHints.VALUE_TEXT_ANTIALIAS_ON, - RenderingHints.VALUE_INTERPOLATION_BICUBIC); - - public static final QualityHints GOOD_QUALITY_HINTS = - new QualityHints(RenderingHints.VALUE_RENDER_DEFAULT, - RenderingHints.VALUE_ANTIALIAS_ON, - RenderingHints.VALUE_TEXT_ANTIALIAS_ON, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - - public static final QualityHints LOW_QUALITY_HINTS = - new QualityHints(RenderingHints.VALUE_RENDER_SPEED, - RenderingHints.VALUE_ANTIALIAS_OFF, - RenderingHints.VALUE_TEXT_ANTIALIAS_OFF, - RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); - - public static QualityHints getHints(Quality forQuality) { - if (forQuality == null) - return null; - switch (forQuality) { - case GOOD: return GOOD_QUALITY_HINTS; - case HIGH: return HIGH_QUALITY_HINTS; - case LOW: return LOW_QUALITY_HINTS; - default: return HIGH_QUALITY_HINTS; - } - } - - public final Object rendering; - public final Object antialiasing; - public final Object textAntiAliasing; - public final Object interpolation; - - public QualityHints(Object rendering, Object antialiasing, Object textAntiAliasing, Object interpolation) { - this.rendering = rendering; - this.antialiasing = antialiasing; - this.textAntiAliasing = textAntiAliasing; - this.interpolation = interpolation; - } - - public void setQuality(Graphics2D g) { - if (rendering!=null) - g.setRenderingHint(RenderingHints.KEY_RENDERING, rendering); - if (antialiasing!=null) - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialiasing); - if (textAntiAliasing!=null) - g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, textAntiAliasing); - if (interpolation!=null) - g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, interpolation); - } - - public static QualityHints getQuality(Graphics2D g) { - return new QualityHints( - g.getRenderingHint(RenderingHints.KEY_RENDERING), - g.getRenderingHint(RenderingHints.KEY_ANTIALIASING), - g.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING), - g.getRenderingHint(RenderingHints.KEY_INTERPOLATION) - ); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.scenegraph.utils; + +import java.awt.Graphics2D; +import java.awt.RenderingHints; + +/** + * Rendering quality hints + * + * @author Toni Kalajainen + */ +public class QualityHints { + + public static final QualityHints HIGH_QUALITY_HINTS = + new QualityHints(RenderingHints.VALUE_RENDER_QUALITY, + RenderingHints.VALUE_ANTIALIAS_ON, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + + public static final QualityHints GOOD_QUALITY_HINTS = + new QualityHints(RenderingHints.VALUE_RENDER_DEFAULT, + RenderingHints.VALUE_ANTIALIAS_ON, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON, + RenderingHints.VALUE_INTERPOLATION_BILINEAR); + + public static final QualityHints LOW_QUALITY_HINTS = + new QualityHints(RenderingHints.VALUE_RENDER_SPEED, + RenderingHints.VALUE_ANTIALIAS_OFF, + RenderingHints.VALUE_TEXT_ANTIALIAS_OFF, + RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); + + public static QualityHints getHints(Quality forQuality) { + if (forQuality == null) + return null; + switch (forQuality) { + case GOOD: return GOOD_QUALITY_HINTS; + case HIGH: return HIGH_QUALITY_HINTS; + case LOW: return LOW_QUALITY_HINTS; + default: return HIGH_QUALITY_HINTS; + } + } + + public final Object rendering; + public final Object antialiasing; + public final Object textAntiAliasing; + public final Object interpolation; + + public QualityHints(Object rendering, Object antialiasing, Object textAntiAliasing, Object interpolation) { + this.rendering = rendering; + this.antialiasing = antialiasing; + this.textAntiAliasing = textAntiAliasing; + this.interpolation = interpolation; + } + + public void setQuality(Graphics2D g) { + if (rendering!=null) + g.setRenderingHint(RenderingHints.KEY_RENDERING, rendering); + if (antialiasing!=null) + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialiasing); + if (textAntiAliasing!=null) + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, textAntiAliasing); + if (interpolation!=null) + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, interpolation); + } + + public static QualityHints getQuality(Graphics2D g) { + return new QualityHints( + g.getRenderingHint(RenderingHints.KEY_RENDERING), + g.getRenderingHint(RenderingHints.KEY_ANTIALIASING), + g.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING), + g.getRenderingHint(RenderingHints.KEY_INTERPOLATION) + ); + } + +}