Search in sources :

Example 21 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project jmeter by apache.

the class JMeterMenuBar method getAllLAFs.

/**
 * Get a list of all installed LAFs plus CrossPlatform and System.
 *
 * @return The list of available {@link LookAndFeelInfo}s
 */
// This is also used by LookAndFeelCommand
public static LookAndFeelInfo[] getAllLAFs() {
    UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
    int i = lafs.length;
    UIManager.LookAndFeelInfo[] lafsAll = new UIManager.LookAndFeelInfo[i + 2];
    System.arraycopy(lafs, 0, lafsAll, 0, i);
    lafsAll[i++] = new UIManager.LookAndFeelInfo(CROSS_PLATFORM_LAF, UIManager.getCrossPlatformLookAndFeelClassName());
    lafsAll[i] = new UIManager.LookAndFeelInfo(SYSTEM_LAF, UIManager.getSystemLookAndFeelClassName());
    return lafsAll;
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) UIManager(javax.swing.UIManager)

Example 22 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project joons-renderer by joonhyublee.

the class SunflowGUI method main.

public static void main(String[] args) {
    if (args.length > 0) {
        boolean showFrame = true;
        String sampler = null;
        boolean noRender = false;
        String filename = null;
        String input = null;
        int i = 0;
        int threads = 0;
        boolean lowPriority = true;
        boolean showAA = false;
        boolean noGI = false;
        boolean noCaustics = false;
        int pathGI = 0;
        float maxDist = 0;
        String shaderOverride = null;
        int resolutionW = 0, resolutionH = 0;
        int aaMin = -5, aaMax = -5;
        int samples = -1;
        int bucketSize = 0;
        String bucketOrder = null;
        String bakingName = null;
        boolean bakeViewdep = false;
        String filterType = null;
        boolean runBenchmark = false;
        boolean runRTBenchmark = false;
        String translateFilename = null;
        int frameStart = 1, frameStop = 1;
        while (i < args.length) {
            if (args[i].equals("-o")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                filename = args[i + 1];
                i += 2;
            } else if (args[i].equals("-nogui")) {
                showFrame = false;
                i++;
            } else if (args[i].equals("-ipr")) {
                sampler = "ipr";
                i++;
            } else if (args[i].equals("-threads")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                threads = Integer.parseInt(args[i + 1]);
                i += 2;
            } else if (args[i].equals("-lopri")) {
                lowPriority = true;
                i++;
            } else if (args[i].equals("-hipri")) {
                lowPriority = false;
                i++;
            } else if (args[i].equals("-sampler")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                sampler = args[i + 1];
                i += 2;
            } else if (args[i].equals("-smallmesh")) {
                TriangleMesh.setSmallTriangles(true);
                i++;
            } else if (args[i].equals("-dumpkd")) {
                KDTree.setDumpMode(true, "kdtree");
                i++;
            } else if (args[i].equals("-buildonly")) {
                noRender = true;
                i++;
            } else if (args[i].equals("-showaa")) {
                showAA = true;
                i++;
            } else if (args[i].equals("-nogi")) {
                noGI = true;
                i++;
            } else if (args[i].equals("-nocaustics")) {
                noCaustics = true;
                i++;
            } else if (args[i].equals("-pathgi")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                pathGI = Integer.parseInt(args[i + 1]);
                i += 2;
            } else if (args[i].equals("-quick_ambocc")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                maxDist = Float.parseFloat(args[i + 1]);
                // new
                shaderOverride = "ambient_occlusion";
                // AmbientOcclusionShader(Color.WHITE,
                // d);
                i += 2;
            } else if (args[i].equals("-quick_uvs")) {
                if (i > args.length - 1) {
                    usage(false);
                }
                shaderOverride = "show_uvs";
                i++;
            } else if (args[i].equals("-quick_normals")) {
                if (i > args.length - 1) {
                    usage(false);
                }
                shaderOverride = "show_normals";
                i++;
            } else if (args[i].equals("-quick_id")) {
                if (i > args.length - 1) {
                    usage(false);
                }
                shaderOverride = "show_instance_id";
                i++;
            } else if (args[i].equals("-quick_prims")) {
                if (i > args.length - 1) {
                    usage(false);
                }
                shaderOverride = "show_primitive_id";
                i++;
            } else if (args[i].equals("-quick_gray")) {
                if (i > args.length - 1) {
                    usage(false);
                }
                shaderOverride = "quick_gray";
                i++;
            } else if (args[i].equals("-quick_wire")) {
                if (i > args.length - 1) {
                    usage(false);
                }
                shaderOverride = "wireframe";
                i++;
            } else if (args[i].equals("-resolution")) {
                if (i > args.length - 3) {
                    usage(false);
                }
                resolutionW = Integer.parseInt(args[i + 1]);
                resolutionH = Integer.parseInt(args[i + 2]);
                i += 3;
            } else if (args[i].equals("-aa")) {
                if (i > args.length - 3) {
                    usage(false);
                }
                aaMin = Integer.parseInt(args[i + 1]);
                aaMax = Integer.parseInt(args[i + 2]);
                i += 3;
            } else if (args[i].equals("-samples")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                samples = Integer.parseInt(args[i + 1]);
                i += 2;
            } else if (args[i].equals("-bucket")) {
                if (i > args.length - 3) {
                    usage(false);
                }
                bucketSize = Integer.parseInt(args[i + 1]);
                bucketOrder = args[i + 2];
                i += 3;
            } else if (args[i].equals("-bake")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                bakingName = args[i + 1];
                i += 2;
            } else if (args[i].equals("-bakedir")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                String baketype = args[i + 1];
                if (baketype.equals("view")) {
                    bakeViewdep = true;
                } else if (baketype.equals("ortho")) {
                    bakeViewdep = false;
                } else {
                    usage(false);
                }
                i += 2;
            } else if (args[i].equals("-filter")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                filterType = args[i + 1];
                i += 2;
            } else if (args[i].equals("-bench")) {
                runBenchmark = true;
                i++;
            } else if (args[i].equals("-rtbench")) {
                runRTBenchmark = true;
                i++;
            } else if (args[i].equals("-frame")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                frameStart = frameStop = Integer.parseInt(args[i + 1]);
                i += 2;
            } else if (args[i].equals("-anim")) {
                if (i > args.length - 3) {
                    usage(false);
                }
                frameStart = Integer.parseInt(args[i + 1]);
                frameStop = Integer.parseInt(args[i + 2]);
                i += 3;
            } else if (args[i].equals("-v")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                UI.verbosity(Integer.parseInt(args[i + 1]));
                i += 2;
            } else if (args[i].equals("-translate")) {
                if (i > args.length - 2) {
                    usage(false);
                }
                translateFilename = args[i + 1];
                i += 2;
            } else if (args[i].equals("-h") || args[i].equals("-help")) {
                usage(true);
            } else {
                if (input != null) {
                    usage(false);
                }
                input = args[i];
                i++;
            }
        }
        if (runBenchmark) {
            SunflowAPI.runSystemCheck();
            new Benchmark().execute();
            return;
        }
        if (runRTBenchmark) {
            SunflowAPI.runSystemCheck();
            new RealtimeBenchmark(showFrame, threads);
            return;
        }
        if (input == null) {
            usage(false);
        }
        SunflowAPI.runSystemCheck();
        if (translateFilename != null) {
            SunflowAPI.translate(input, translateFilename);
            return;
        }
        if (frameStart < frameStop && showFrame) {
            UI.printWarning(Module.GUI, "Animations should not be rendered without -nogui - forcing GUI off anyway");
            showFrame = false;
        }
        if (frameStart < frameStop && filename == null) {
            filename = "output.#.png";
            UI.printWarning(Module.GUI, "Animation output was not specified - defaulting to: \"%s\"", filename);
        }
        for (int frameNumber = frameStart; frameNumber <= frameStop; frameNumber++) {
            SunflowAPI api = SunflowAPI.create(input, frameNumber);
            if (api == null) {
                continue;
            }
            if (noRender) {
                continue;
            }
            if (resolutionW > 0 && resolutionH > 0) {
                api.parameter("resolutionX", resolutionW);
                api.parameter("resolutionY", resolutionH);
            }
            if (aaMin != -5 || aaMax != -5) {
                api.parameter("aa.min", aaMin);
                api.parameter("aa.max", aaMax);
            }
            if (samples >= 0) {
                api.parameter("aa.samples", samples);
            }
            if (bucketSize > 0) {
                api.parameter("bucket.size", bucketSize);
            }
            if (bucketOrder != null) {
                api.parameter("bucket.order", bucketOrder);
            }
            api.parameter("aa.display", showAA);
            api.parameter("threads", threads);
            api.parameter("threads.lowPriority", lowPriority);
            if (bakingName != null) {
                api.parameter("baking.instance", bakingName);
                api.parameter("baking.viewdep", bakeViewdep);
            }
            if (filterType != null) {
                api.parameter("filter", filterType);
            }
            if (noGI) {
                api.parameter("gi.engine", "none");
            } else if (pathGI > 0) {
                api.parameter("gi.engine", "path");
                api.parameter("gi.path.samples", pathGI);
            }
            if (noCaustics) {
                api.parameter("caustics", "none");
            }
            if (sampler != null) {
                api.parameter("sampler", sampler);
            }
            api.options(SunflowAPI.DEFAULT_OPTIONS);
            if (shaderOverride != null) {
                if (shaderOverride.equals("ambient_occlusion")) {
                    api.parameter("maxdist", maxDist);
                }
                api.shader("cmdline_override", shaderOverride);
                api.parameter("override.shader", "cmdline_override");
                api.parameter("override.photons", true);
                api.options(SunflowAPI.DEFAULT_OPTIONS);
            }
            // create display
            Display display;
            String currentFilename = (filename != null) ? filename.replace("#", String.format("%04d", frameNumber)) : null;
            if (showFrame) {
                display = new FrameDisplay(currentFilename);
            } else {
                if (currentFilename != null && currentFilename.equals("imgpipe")) {
                    display = new ImgPipeDisplay();
                } else {
                    display = new FileDisplay(currentFilename);
                }
            }
            api.render(SunflowAPI.DEFAULT_OPTIONS, display);
        }
    } else {
        try {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception e) {
            // If Nimbus is not available, you can set the GUI to another look and feel.
            MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
        }
        SunflowGUI gui = new SunflowGUI();
        gui.setVisible(true);
        Dimension screenRes = Toolkit.getDefaultToolkit().getScreenSize();
        if (screenRes.getWidth() <= DEFAULT_WIDTH || screenRes.getHeight() <= DEFAULT_HEIGHT) {
            gui.setExtendedState(MAXIMIZED_BOTH);
        }
        gui.tileWindowMenuItem.doClick();
        SunflowAPI.runSystemCheck();
    }
}
Also used : FrameDisplay(org.sunflow.core.display.FrameDisplay) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) Dimension(java.awt.Dimension) PropertyVetoException(java.beans.PropertyVetoException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme) ImgPipeDisplay(org.sunflow.core.display.ImgPipeDisplay) SunflowAPI(org.sunflow.SunflowAPI) RealtimeBenchmark(org.sunflow.RealtimeBenchmark) Benchmark(org.sunflow.Benchmark) RealtimeBenchmark(org.sunflow.RealtimeBenchmark) FileDisplay(org.sunflow.core.display.FileDisplay) Display(org.sunflow.core.Display) FrameDisplay(org.sunflow.core.display.FrameDisplay) FileDisplay(org.sunflow.core.display.FileDisplay) ImgPipeDisplay(org.sunflow.core.display.ImgPipeDisplay)

Example 23 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project megameklab by MegaMek.

the class MenuBar method createThemeMenu.

/**
 * Creates a menu that includes all installed look and feel options
 *
 * @return The new menu
 */
private JMenu createThemeMenu() {
    JMenu menu = new JMenu(resourceMap.getString("menu.file.themes"));
    JCheckBoxMenuItem item;
    for (LookAndFeelInfo plaf : UIManager.getInstalledLookAndFeels()) {
        item = new JCheckBoxMenuItem(plaf.getName());
        if (plaf.getName().equalsIgnoreCase(UIManager.getLookAndFeel().getName())) {
            item.setSelected(true);
        }
        menu.add(item);
        item.addActionListener(ev -> {
            parentFrame.changeTheme(plaf);
            refreshThemeMenu(plaf.getName());
        });
    }
    return menu;
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo)

Example 24 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project jitsi by jitsi.

the class UIServiceImpl method setDefaultThemePack.

/**
     * Sets the look&feel and the theme.
     */
private void setDefaultThemePack() {
    // Show tooltips immediately and specify a custom background.
    ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
    UIManager.put("ToolTip.background", new Color(GuiActivator.getResources().getColor("service.gui.TOOLTIP_BACKGROUND")));
    toolTipManager.setInitialDelay(500);
    toolTipManager.setDismissDelay(60000);
    toolTipManager.setEnabled(true);
    // we need to set the UIDefaults class loader so that it may access
    // resources packed inside OSGI bundles
    UIManager.put("ClassLoader", getClass().getClassLoader());
    /*
         * Attempt to use the OS-native LookAndFeel instead of
         * SIPCommLookAndFeel.
         */
    String laf = UIManager.getSystemLookAndFeelClassName();
    boolean lafIsSet = false;
    /*
         * SIPCommLookAndFeel used to be set in case the system L&F was the same
         * as the cross-platform L&F. Unfortunately, SIPCommLookAndFeel is now
         * broken because its classes are loaded by different ClassLoaders which
         * results in exceptions. That's why the check
         * !laf.equals(UIManager.getCrossPlatformLookAndFeelClassName()) is
         * removed from the if statement bellow and thus the cross-platform L&F
         * is preferred over SIPCommLookAndFeel.
         */
    if (laf != null) {
        /*
             * Swing does not have a LookAndFeel which integrates with KDE and
             * the cross-platform LookAndFeel is plain ugly. KDE integrates with
             * GTK+ so try to use the GTKLookAndFeel when running in KDE.
             */
        String gtkLookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        if ((OSUtils.IS_FREEBSD || OSUtils.IS_LINUX) && laf.equals(UIManager.getCrossPlatformLookAndFeelClassName())) {
            try {
                String kdeFullSession = System.getenv("KDE_FULL_SESSION");
                if ((kdeFullSession != null) && (kdeFullSession.length() != 0)) {
                    for (LookAndFeelInfo lafi : UIManager.getInstalledLookAndFeels()) {
                        if (gtkLookAndFeel.equals(lafi.getClassName())) {
                            laf = gtkLookAndFeel;
                            break;
                        }
                    }
                }
            } catch (Throwable t) {
                if (t instanceof ThreadDeath)
                    throw (ThreadDeath) t;
            }
        }
        try {
            UIManager.setLookAndFeel(laf);
            lafIsSet = true;
            UIDefaults uiDefaults = UIManager.getDefaults();
            if (OSUtils.IS_WINDOWS)
                fixWindowsUIDefaults(uiDefaults);
            // "GNOME SCScrollPane has rounded and rectangular borders"
            if (laf.equals(gtkLookAndFeel) || laf.equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel")) {
                uiDefaults.put("ScrollPaneUI", new javax.swing.plaf.metal.MetalLookAndFeel().getDefaults().get("ScrollPaneUI"));
            }
        } catch (ClassNotFoundException ex) {
        /*
                 * Ignore the exceptions because we're only trying to set the
                 * native LookAndFeel and, if it fails, we'll use
                 * SIPCommLookAndFeel.
                 */
        } catch (InstantiationException ex) {
        } catch (IllegalAccessException ex) {
        } catch (UnsupportedLookAndFeelException ex) {
        }
    }
    if (!lafIsSet) {
        try {
            SIPCommLookAndFeel lf = new SIPCommLookAndFeel();
            SIPCommLookAndFeel.setCurrentTheme(new SIPCommDefaultTheme());
            // appropriate default decoration.
            if (Boolean.parseBoolean(GuiActivator.getResources().getSettingsString("impl.gui.IS_LOOK_AND_FEEL_DECORATED"))) {
                JFrame.setDefaultLookAndFeelDecorated(true);
                JDialog.setDefaultLookAndFeelDecorated(true);
            }
            UIManager.setLookAndFeel(lf);
        } catch (UnsupportedLookAndFeelException ex) {
            logger.error("The provided Look & Feel is not supported.", ex);
        }
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) javax.swing(javax.swing)

Example 25 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project smile by haifengl.

the class SmileDemo method createAndShowGUI.

/**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event dispatch thread.
     */
public static void createAndShowGUI(boolean exitOnClose) {
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception ex) {
        try {
            // If Nimbus is not available, try system look and feel.
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.err.println(e);
        }
    }
    //Create and set up the window.
    JFrame frame = new JFrame("Smile Demo");
    frame.setSize(new Dimension(1000, 1000));
    frame.setLocationRelativeTo(null);
    if (exitOnClose)
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    else
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    //Add content to the window.
    frame.add(new SmileDemo());
    //Display the window.
    frame.pack();
    frame.setVisible(true);
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) JFrame(javax.swing.JFrame) Dimension(java.awt.Dimension) IOException(java.io.IOException)

Aggregations

LookAndFeelInfo (javax.swing.UIManager.LookAndFeelInfo)41 IOException (java.io.IOException)7 JPanel (javax.swing.JPanel)6 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)6 Dimension (java.awt.Dimension)5 JFrame (javax.swing.JFrame)5 JLabel (javax.swing.JLabel)4 BorderLayout (java.awt.BorderLayout)3 File (java.io.File)3 JFileChooser (javax.swing.JFileChooser)3 Color (java.awt.Color)2 FlowLayout (java.awt.FlowLayout)2 GridLayout (java.awt.GridLayout)2 JButton (javax.swing.JButton)2 JTextField (javax.swing.JTextField)2 PropertiesPreferences (com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences)1 MessagesService (com.igormaznitsa.sciareto.notifications.MessagesService)1 PrinterPlugin (com.igormaznitsa.sciareto.plugins.services.PrinterPlugin)1 MainFrame (com.igormaznitsa.sciareto.ui.MainFrame)1 SplashScreen (com.igormaznitsa.sciareto.ui.UiUtils.SplashScreen)1