Search in sources :

Example 6 with EasikSettings

use of easik.EasikSettings in project fql by CategoricalData.

the class ProgramSettingsUI method addGeneralOptions.

/**
 * Adds the options for the General tab to the passed-in OptionTab
 *
 * @param general
 */
protected void addGeneralOptions(OptionTab general) {
    EasikSettings s = Easik.getInstance().getSettings();
    general.addOption(new JLabel("Default folder"), folderPanel(s));
    JPanel settings = new JPanel();
    settings.setLayout(new BoxLayout(settings, BoxLayout.Y_AXIS));
    _showAttsAndUniqueKeys = new JCheckBox("Show attributes & unique keys", s.getProperty("attrib_display", "show").equals("show"));
    // _showWarnings = new JCheckBox("Show warnings",
    // s.getProperty("warning_display", "show").equals("show"));
    settings.add(_showAttsAndUniqueKeys);
    // settings.add(_showWarnings);
    general.addOption(new JLabel("Startup settings"), settings);
    float currentScale = s.getFloat("thumb_scale_factor", 0.25f);
    thumbScaleSlider = new JSlider(1, 100, (int) (100 * currentScale));
    Dimension d = thumbScaleSlider.getPreferredSize();
    thumbScaleSlider.setPreferredSize(new Dimension(200, d.height));
    final JLabel thumbScaleIndicator = new JLabel((currentScale + "").replaceAll("\\.?0+$", ""));
    thumbScaleSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider s = (JSlider) e.getSource();
            @SuppressWarnings("unused") JPanel p = (JPanel) s.getParent();
            thumbScaleIndicator.setText(((s.getValue() / 100.0) + "").replaceAll("\\.?0+$", ""));
        }
    });
    String scaleTT = JUtils.tooltip("The scale affects how large the thumbnail of sketches and views shows in the overview will be.  A value of 0.25 (the default) means 1/4 size; 0.5 would mean 1/2 size.");
    JLabel scaleLabel = new JLabel("Thumbnail scale");
    scaleLabel.setToolTipText(scaleTT);
    thumbScaleSlider.setToolTipText(scaleTT);
    general.addOption(new Option(scaleLabel, thumbScaleSlider, thumbScaleIndicator));
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) EasikSettings(easik.EasikSettings) JCheckBox(javax.swing.JCheckBox) ChangeEvent(javax.swing.event.ChangeEvent) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener)

Example 7 with EasikSettings

use of easik.EasikSettings in project fql by CategoricalData.

the class FileChooser method chooseFileSwing.

/**
 * @param title
 * @param mode
 * @param filter
 *
 * @return
 */
private static File chooseFileSwing(String title, Mode mode, FileFilter filter, String defaultName) {
    Easik e = Easik.getInstance();
    EasikSettings s = e.getSettings();
    JFileChooser dialog = new JFileChooser(s.getDefaultFolder());
    if (filter != null) {
        dialog.setFileFilter(filter);
    }
    int result;
    if (mode == Mode.DIRECTORY) {
        dialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        result = dialog.showDialog(e.getFrame(), "Select folder");
    } else if (mode == Mode.SAVE) {
        if (defaultName != null) {
            dialog.setSelectedFile(new File(defaultName));
        }
        result = dialog.showSaveDialog(e.getFrame());
    } else {
        result = dialog.showOpenDialog(e.getFrame());
    }
    if (result != JFileChooser.APPROVE_OPTION) {
        return null;
    }
    File selFile = dialog.getSelectedFile();
    if (mode != Mode.DIRECTORY) {
        s.setProperty("folder_last", selFile.getParentFile().getAbsolutePath());
    }
    return selFile;
}
Also used : Easik(easik.Easik) JFileChooser(javax.swing.JFileChooser) File(java.io.File) EasikSettings(easik.EasikSettings)

Aggregations

EasikSettings (easik.EasikSettings)7 JLabel (javax.swing.JLabel)3 JPanel (javax.swing.JPanel)3 JSlider (javax.swing.JSlider)3 Easik (easik.Easik)2 Dimension (java.awt.Dimension)2 File (java.io.File)2 BoxLayout (javax.swing.BoxLayout)2 JCheckBox (javax.swing.JCheckBox)2 ChangeEvent (javax.swing.event.ChangeEvent)2 ChangeListener (javax.swing.event.ChangeListener)2 ModelConstraint (easik.model.constraint.ModelConstraint)1 Color (java.awt.Color)1 Component (java.awt.Component)1 FileDialog (java.awt.FileDialog)1 GradientPaint (java.awt.GradientPaint)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ButtonGroup (javax.swing.ButtonGroup)1 JComboBox (javax.swing.JComboBox)1