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;
}
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");
}
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)));
}
}
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();
}
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;
}
Aggregations