Search in sources :

Example 16 with BevelBorder

use of javax.swing.border.BevelBorder in project servoy-client by Servoy.

the class BorderPropertyType method writeBorderToJson.

public static Map<String, Object> writeBorderToJson(Border value) {
    Map<String, Object> map = new HashMap<>();
    if (value instanceof SpecialMatteBorder) {
        SpecialMatteBorder border = (SpecialMatteBorder) value;
        map.put(TYPE, ((border instanceof RoundedBorder) ? ComponentFactoryHelper.ROUNDED_BORDER : ComponentFactoryHelper.SPECIAL_MATTE_BORDER));
        Map<String, Object> borderStyle = new HashMap<>();
        map.put(BORDER_STYLE, borderStyle);
        borderStyle.put(BORDER_TOP_WIDTH, border.getTop() + "px");
        borderStyle.put(BORDER_RIGHT_WIDTH, border.getRight() + "px");
        borderStyle.put(BORDER_BOTTOM_WIDTH, border.getBottom() + "px");
        borderStyle.put(BORDER_LEFT_WIDTH, border.getLeft() + "px");
        borderStyle.put(BORDER_TOP_COLOR, border.getTopColor());
        borderStyle.put(BORDER_RIGHT_COLOR, border.getRightColor());
        borderStyle.put(BORDER_BOTTOM_COLOR, border.getBottomColor());
        borderStyle.put(BORDER_LEFT_COLOR, border.getLeftColor());
        if (border instanceof RoundedBorder) {
            float[] radius = ((RoundedBorder) border).getRadius();
            borderStyle.put(BORDER_RADIUS, radius[0] + "px " + radius[2] + "px " + radius[4] + "px " + radius[6] + "px /" + radius[1] + "px " + radius[3] + "px " + radius[5] + "px " + radius[7] + "px");
            String[] styles = ((RoundedBorder) border).getBorderStyles();
            borderStyle.put(BORDER_STYLE, styles[0] + " " + styles[1] + " " + styles[2] + " " + styles[3]);
        } else {
            // $NON-NLS-1$
            borderStyle.put(BORDER_RADIUS, border.getRoundingRadius() + "px");
            // retval += "," + SpecialMatteBorder.createDashString(border.getDashPattern()); //$NON-NLS-1$
            if (border.getDashPattern() != null) {
                borderStyle.put(BORDER_STYLE, "dashed");
            } else {
                borderStyle.put(BORDER_STYLE, "solid");
            }
        }
    } else if (value instanceof EtchedBorder) {
        EtchedBorder border = (EtchedBorder) value;
        map.put(TYPE, ComponentFactoryHelper.ETCHED_BORDER);
        Map<String, Object> borderStyle = new HashMap<>();
        map.put(BORDER_STYLE, borderStyle);
        String hi = PersistHelper.createColorString(border.getHighlightColor());
        String sh = PersistHelper.createColorString(border.getShadowColor());
        if (border.getEtchType() != EtchedBorder.RAISED) {
            String tmp = hi;
            hi = sh;
            sh = tmp;
        }
        borderStyle.put(BORDER_COLOR, hi + " " + sh + " " + sh + " " + hi);
        borderStyle.put(BORDER_STYLE, border.getEtchType() == EtchedBorder.RAISED ? "ridge" : "groove");
        borderStyle.put(BORDER_WIDTH, "2px");
    } else if (value instanceof BevelBorder) {
        BevelBorder border = (BevelBorder) value;
        map.put(TYPE, ComponentFactoryHelper.BEVEL_BORDER);
        Map<String, Object> borderStyle = new HashMap<>();
        map.put(BORDER_STYLE, borderStyle);
        borderStyle.put(BORDER_STYLE, border.getBevelType() == BevelBorder.RAISED ? "outset" : "inset");
        String hiOut = PersistHelper.createColorString(border.getHighlightOuterColor());
        String hiin = PersistHelper.createColorString(border.getHighlightInnerColor());
        String shOut = PersistHelper.createColorString(border.getShadowOuterColor());
        String shIn = PersistHelper.createColorString(border.getShadowInnerColor());
        if (border.getBevelType() == BevelBorder.LOWERED) {
            // swap 1-3
            String temp = hiOut;
            hiOut = shOut;
            shOut = temp;
            // swap 2-4
            temp = hiin;
            hiin = shIn;
            shIn = temp;
        }
        borderStyle.put(BORDER_COLOR, hiOut + " " + shOut + " " + shIn + " " + hiin);
        borderStyle.put(BORDER_WIDTH, "2px");
    } else if (value instanceof LineBorder) {
        LineBorder border = (LineBorder) value;
        map.put(TYPE, ComponentFactoryHelper.LINE_BORDER);
        Map<String, Object> borderStyle = new HashMap<>();
        map.put(BORDER_STYLE, borderStyle);
        int thick = border.getThickness();
        borderStyle.put(BORDER_COLOR, border.getLineColor());
        borderStyle.put(BORDER_STYLE, "solid");
        borderStyle.put(BORDER_WIDTH, thick + "px");
    } else if (value instanceof MatteBorder) {
        MatteBorder border = (MatteBorder) value;
        map.put(TYPE, ComponentFactoryHelper.MATTE_BORDER);
        Map<String, Object> borderStyle = new HashMap<>();
        map.put(BORDER_STYLE, borderStyle);
        Insets in = border.getBorderInsets();
        borderStyle.put(BORDER_WIDTH, in.top + "px " + in.right + "px " + in.bottom + "px " + in.left + "px ");
        borderStyle.put(BORDER_COLOR, border.getMatteColor());
        borderStyle.put(BORDER_STYLE, "solid");
    } else if (value instanceof EmptyBorder) {
        EmptyBorder border = (EmptyBorder) value;
        map.put(TYPE, ComponentFactoryHelper.EMPTY_BORDER);
        Map<String, Object> borderStyle = new HashMap<>();
        map.put(BORDER_STYLE, borderStyle);
        Insets in = border.getBorderInsets();
        borderStyle.put(BORDER_WIDTH, in.top + "px " + in.right + "px " + in.bottom + "px " + in.left + "px ");
        borderStyle.put(BORDER_COLOR, "rgba(0,0,0,0)");
    } else if (value instanceof TitledBorder) {
        TitledBorder border = (TitledBorder) value;
        map.put(TYPE, ComponentFactoryHelper.TITLED_BORDER);
        map.put(TITLE, border.getTitle());
        map.put("font", border.getTitleFont());
        map.put("color", border.getTitleColor());
        int just = border.getTitleJustification();
        String titleJust = "left";
        switch(just) {
            case TitledBorder.LEFT:
                titleJust = "left";
                break;
            case TitledBorder.RIGHT:
                titleJust = "right";
                break;
            case TitledBorder.CENTER:
                titleJust = "center";
                break;
            case TitledBorder.LEADING:
                titleJust = "leading";
                break;
            case TitledBorder.TRAILING:
                titleJust = "trailing";
                break;
        }
        map.put(TITLE_JUSTIFICATION, titleJust);
        String titlePosition = "Top";
        switch(border.getTitlePosition()) {
            case TitledBorder.ABOVE_TOP:
                titlePosition = "Above top";
                break;
            case TitledBorder.BELOW_TOP:
                titlePosition = "Below top";
                break;
            case TitledBorder.ABOVE_BOTTOM:
                titlePosition = "Above bottom";
                break;
            case TitledBorder.BELOW_BOTTOM:
                titlePosition = "Below bottom";
                break;
            case TitledBorder.BOTTOM:
                titlePosition = "Bottom";
                break;
        }
        map.put(TITLE_POSITION, titlePosition);
    }
    return map;
}
Also used : Insets(java.awt.Insets) HashMap(java.util.HashMap) BevelBorder(javax.swing.border.BevelBorder) SpecialMatteBorder(com.servoy.j2db.util.gui.SpecialMatteBorder) LineBorder(javax.swing.border.LineBorder) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder) SpecialMatteBorder(com.servoy.j2db.util.gui.SpecialMatteBorder) MatteBorder(javax.swing.border.MatteBorder) JSONObject(org.json.JSONObject) RoundedBorder(com.servoy.j2db.util.gui.RoundedBorder) EmptyBorder(javax.swing.border.EmptyBorder) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with BevelBorder

use of javax.swing.border.BevelBorder in project micro-manager by micro-manager.

the class PropertyEditor method createComponents.

private void createComponents() {
    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/org/micromanager/icons/microscope.gif")));
    setLayout(new MigLayout("fill, insets 2, flowy"));
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            flags_.save(PropertyEditor.class);
        }

        @Override
        public void windowOpened(WindowEvent e) {
            // restore values from the previous session
            data_.update(false);
            data_.fireTableStructureChanged();
        }
    });
    setTitle("Device Property Browser");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JButton refreshButton = new JButton("Refresh", new ImageIcon(getClass().getResource("/org/micromanager/icons/arrow_refresh.png")));
    Font defaultFont = new Font("Arial", Font.PLAIN, 10);
    add(new ShowFlagsPanel(data_, flags_, core_, core_.getSystemStateCache()), "split 2, aligny top, gapbottom 10");
    refreshButton.setFont(defaultFont);
    refreshButton.addActionListener((ActionEvent e) -> {
        refresh(false);
    });
    add(refreshButton, "width 100!, center, wrap");
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(table_);
    scrollPane.setFont(defaultFont);
    scrollPane.setBorder(new BevelBorder(BevelBorder.LOWERED));
    add(scrollPane, "span, grow, push, wrap");
}
Also used : JScrollPane(javax.swing.JScrollPane) ImageIcon(javax.swing.ImageIcon) BevelBorder(javax.swing.border.BevelBorder) ActionEvent(java.awt.event.ActionEvent) MigLayout(net.miginfocom.swing.MigLayout) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) ShowFlagsPanel(org.micromanager.internal.utils.ShowFlagsPanel) WindowAdapter(java.awt.event.WindowAdapter) Font(java.awt.Font)

Example 18 with BevelBorder

use of javax.swing.border.BevelBorder in project micro-manager by micro-manager.

the class ConfigDialog method initializePropertyTable.

public void initializePropertyTable() {
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setFont(new Font("Arial", Font.PLAIN, 10));
    scrollPane.setBorder(new BevelBorder(BevelBorder.LOWERED));
    int extraWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
    add(scrollPane, "flowy, span, growx, growy, push, width pref+" + extraWidth + "px");
    table_ = new DaytimeNighttime.Table();
    table_.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table_.setAutoCreateColumnsFromModel(false);
    scrollPane.setViewportView(table_);
    table_.setModel(data_);
    if (numColumns_ == 3) {
        table_.addColumn(new TableColumn(0, 200, new PropertyNameCellRenderer(studio_), null));
        table_.addColumn(new TableColumn(1, 75, new PropertyUsageCellRenderer(studio_), new PropertyUsageCellEditor()));
        table_.addColumn(new TableColumn(2, 200, new PropertyValueCellRenderer(studio_), new PropertyValueCellEditor(true)));
    } else if (numColumns_ == 2) {
        table_.addColumn(new TableColumn(0, 200, new PropertyNameCellRenderer(studio_), null));
        table_.addColumn(new TableColumn(1, 200, new PropertyValueCellRenderer(studio_), new PropertyValueCellEditor(false)));
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) PropertyValueCellRenderer(org.micromanager.internal.utils.PropertyValueCellRenderer) BevelBorder(javax.swing.border.BevelBorder) DaytimeNighttime(org.micromanager.internal.utils.DaytimeNighttime) PropertyValueCellEditor(org.micromanager.internal.utils.PropertyValueCellEditor) TableColumn(javax.swing.table.TableColumn) PropertyUsageCellRenderer(org.micromanager.internal.utils.PropertyUsageCellRenderer) Font(java.awt.Font) PropertyNameCellRenderer(org.micromanager.internal.utils.PropertyNameCellRenderer) PropertyUsageCellEditor(org.micromanager.internal.utils.PropertyUsageCellEditor)

Example 19 with BevelBorder

use of javax.swing.border.BevelBorder in project PACOM by smdb21.

the class ScrollableJTable method initializeUI.

private void initializeUI(int wide) {
    setLayout(new BorderLayout());
    setPreferredSize(new Dimension(wide, 400));
    // 
    // Turn off JTable's auto resize so that JScrollpane
    // will show a horizontal scroll bar.
    // 
    // table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    table.setSize(new Dimension(wide, 400));
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    addProteinACCCellListener();
    final JScrollPane pane = new JScrollPane(table);
    pane.setViewportBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
    add(pane, BorderLayout.CENTER);
    super.repaint();
}
Also used : JScrollPane(javax.swing.JScrollPane) BorderLayout(java.awt.BorderLayout) BevelBorder(javax.swing.border.BevelBorder) Dimension(java.awt.Dimension)

Example 20 with BevelBorder

use of javax.swing.border.BevelBorder in project spotbugs by spotbugs.

the class MainFrameComponentFactory method statusBar.

JPanel statusBar() {
    JPanel statusBar = new JPanel();
    // statusBar.setBackground(Color.WHITE);
    statusBar.setBorder(new BevelBorder(BevelBorder.LOWERED));
    statusBar.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridy = 0;
    constraints.weightx = 1;
    statusBar.add(mainFrame.getStatusBarLabel(), constraints.clone());
    return statusBar;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) BevelBorder(javax.swing.border.BevelBorder)

Aggregations

BevelBorder (javax.swing.border.BevelBorder)39 JPanel (javax.swing.JPanel)11 JScrollPane (javax.swing.JScrollPane)10 Insets (java.awt.Insets)9 JLabel (javax.swing.JLabel)9 BorderLayout (java.awt.BorderLayout)7 FlowLayout (java.awt.FlowLayout)7 ActionEvent (java.awt.event.ActionEvent)7 Dimension (java.awt.Dimension)6 JButton (javax.swing.JButton)6 EmptyBorder (javax.swing.border.EmptyBorder)6 EtchedBorder (javax.swing.border.EtchedBorder)6 TitledBorder (javax.swing.border.TitledBorder)6 Color (java.awt.Color)5 Font (java.awt.Font)5 GridBagConstraints (java.awt.GridBagConstraints)4 GridBagLayout (java.awt.GridBagLayout)4 CompoundBorder (javax.swing.border.CompoundBorder)4 ActionListener (java.awt.event.ActionListener)3 WindowEvent (java.awt.event.WindowEvent)3