package ij.util;
import ij.*;
import ij.Prefs;
import java.awt.*;
import javax.swing.*;
public class Java2 {
public static void setAntialiased(Graphics g, boolean antialiased) {
Graphics2D g2d = (Graphics2D)g;
if (antialiased)
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
else
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
public static void setAntialiasedText(Graphics g, boolean antialiasedText) {
Graphics2D g2d = (Graphics2D)g;
if (antialiasedText)
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
else
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
}
public static int getStringWidth(String s, FontMetrics fontMetrics, Graphics g) {
java.awt.geom.Rectangle2D r = fontMetrics.getStringBounds(s, g);
return (int)r.getWidth();
}
public static void setBilinearInterpolation(Graphics g, boolean bilinearInterpolation) {
Graphics2D g2d = (Graphics2D)g;
if (bilinearInterpolation)
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
else
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
}
public static void setSystemLookAndFeel() {
if (!IJ.isWindows())
return;
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Throwable t) {}
}
public static void setLookAndFeel(LookAndFeel newLookAndFeel) {
if (!IJ.isWindows() || newLookAndFeel==null)
return;
try {
UIManager.setLookAndFeel(newLookAndFeel);
} catch(Throwable t) {}
}
public static LookAndFeel getLookAndFeel() {
if (!IJ.isWindows())
return null;
return UIManager.getLookAndFeel();
}
}