/* * * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ package java2d;
controls = new GlobalControls(this);
memorymonitor = new MemoryMonitor();
performancemonitor = new PerformanceMonitor();
GlobalPanel gp = new GlobalPanel(this);
tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT);
tabbedPane.setFont(new Font(Font.SERIF, Font.PLAIN, 12));
tabbedPane.addTab("", new J2DIcon(this), gp);
tabbedPane.addChangeListener(gp);
group = new DemoGroup[demos.length]; for (int i = 0; i < demos.length; i++) {
progress.setText("Loading demos." + demos[i][0]);
group[i] = new DemoGroup(demos[i][0], this);
tabbedPane.addTab(demos[i][0], null);
progress.setValue(progress.getValue() + 1);
}
add(tabbedPane, BorderLayout.CENTER);
}
private JMenuBar createMenuBar() {
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
JMenuBar menuBar = new JMenuBar();
/** * The Icon for the Intro tab.
*/ staticclass J2DIcon implements Icon { privatefinal DemoInstVarsAccessor demoInstVars; privatestaticfinal Color myBlue = new Color(94, 105, 176); privatestaticfinal Color myBlack = new Color(20, 20, 20); privatestaticfinal Font font = new Font(Font.SERIF, Font.BOLD, 12); private FontRenderContext frc = new FontRenderContext(null, true, true); private TextLayout tl = new TextLayout("J2D demo", font, frc);
public J2DIcon(DemoInstVarsAccessor demoInstVars) { this.demoInstVars = demoInstVars;
}
@Override publicvoid paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setFont(font); if (demoInstVars.getTabbedPane().getSelectedIndex() == 0) {
g2.setColor(myBlue);
} else {
g2.setColor(myBlack);
}
tl.draw(g2, x, y + (float)(tl.getBounds().getHeight()));
}
/** * This class eliminates the need in presence of static 'JLabel', 'JProgressBar' * variables in 'J2Ddemo' class. It is a part of the fix which changed static * variables for instance variables in certain demo classes.
*/ publicstaticclass DemoProgress { privatefinal JLabel progressLabel; privatefinal JProgressBar progressBar;
public DemoProgress(JLabel progressLabel, JProgressBar progressBar) { if (progressLabel == null) { thrownew IllegalArgumentException("null was transferred as 'progressLabel' argument");
} if (progressBar == null) { thrownew IllegalArgumentException("null was transferred as 'progressBar' argument");
}
if (runWndSetts.getExit()) {
demo.startRunWindow();
}
}
publicstaticvoid main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override publicvoid run() {
RunWindowSettings runWndSetts = new RunWindowSettings(); for (int i = 0; i < args.length; i++) { if (args[i].startsWith("-h") || args[i].startsWith("-help")) {
String s = "\njava -jar J2Ddemo.jar -runs=5 -delay=5 -screen=5 "
+ "-antialias=true -rendering=true -texture=true "
+ "-composite=true -verbose -print -columns=3 "
+ "-buffers=5,10 -ccthread -zoom -maxscreen \n";
System.out.println(s);
s = " -runs=5 Number of runs to execute\n"
+ " -delay=5 Sleep amount between tabs\n"
+ " -antialias= true or false for antialiasing\n"
+ " -rendering= true or false for quality or speed\n"
+ " -texture= true or false for texturing\n"
+ " -composite= true or false for compositing\n"
+ " -verbose output Surface graphic states \n"
+ " -print during run print the Surface, "
+ "use the Default Printer\n"
+ " -columns=3 # of columns to use in clone layout \n"
+ " -screen=3 demos all use this screen type \n"
+ " -buffers=5,10 during run - clone to see screens "
+ "five through ten\n"
+ " -ccthread Invoke the Custom Controls Thread \n"
+ " -zoom mouseClick on surface for zoom in \n"
+ " -maxscreen take up the entire monitor screen \n";
System.out.println(s);
s = "Examples : \n" + " Print all of the demos : \n"
+ " java -jar J2Ddemo.jar -runs=1 -delay=60 -print \n"
+ " Run zoomed in with custom control thread \n"
+ " java -jar J2Ddemo.jar -runs=10 -zoom -ccthread\n";
System.out.println(s);
System.exit(0);
} elseif (args[i].startsWith("-delay=")) {
String s = args[i].substring(args[i].indexOf('=') + 1);
runWndSetts.setDelay(Integer.parseInt(s));
}
}
initFrame(args, runWndSetts);
}
});
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.3 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.