use of org.apache.pivot.wtk.Theme in project pivot by apache.
the class ColorSchemeBuilderWindow method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
Theme theme = Theme.getTheme();
createColorPalette();
int numberOfPaletteColors = getNumberOfPaletteColors();
themeOriginalColors = new ArrayList<>(numberOfPaletteColors);
for (int i = 0; i < numberOfPaletteColors; i++) {
final ColorChooserButton colorChooserButton = new ColorChooserButton();
colorChooserButtons.add(colorChooserButton);
colorChooserButton.setSelectedColor(Color.BLACK);
NumericSpinnerData colorSpinnerData = new NumericSpinnerData(0, 255);
SpinnerItemRenderer colorSpinnerItemRenderer = new SpinnerItemRenderer();
colorSpinnerItemRenderer.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
final Spinner redSpinner = new Spinner();
redSpinner.setSpinnerData(colorSpinnerData);
redSpinner.setItemRenderer(colorSpinnerItemRenderer);
redSpinner.setPreferredWidth(40);
redSpinner.setSelectedIndex(0);
final Spinner greenSpinner = new Spinner();
greenSpinner.setSpinnerData(colorSpinnerData);
greenSpinner.setItemRenderer(colorSpinnerItemRenderer);
greenSpinner.setPreferredWidth(40);
greenSpinner.setSelectedIndex(0);
final Spinner blueSpinner = new Spinner();
blueSpinner.setSpinnerData(colorSpinnerData);
blueSpinner.setItemRenderer(colorSpinnerItemRenderer);
blueSpinner.setPreferredWidth(40);
blueSpinner.setSelectedIndex(0);
BoxPane colorBoxPane = new BoxPane();
colorBoxPane.getStyles().put(Style.fill, true);
colorBoxPane.getStyles().put(Style.padding, "{left:4}");
colorBoxPane.add(redSpinner);
colorBoxPane.add(greenSpinner);
colorBoxPane.add(blueSpinner);
TablePane.Row row = new TablePane.Row(colorChooserTablePane);
row.add(colorChooserButton);
row.add(colorBoxPane);
// Add listeners
ColorChooserButtonSelectionListener colorChooserButtonSelectionListener = new ColorChooserButtonSelectionListener() {
@Override
public void selectedColorChanged(ColorChooserButton colorChooserButtonArgument, Color previousSelectedColor) {
Color selectedColor = colorChooserButtonArgument.getSelectedColor();
redSpinner.setSelectedItem(selectedColor.getRed());
greenSpinner.setSelectedItem(selectedColor.getGreen());
blueSpinner.setSelectedItem(selectedColor.getBlue());
// Update the theme
Theme themeLocal = Theme.getTheme();
int iLocal = colorChooserButtons.indexOf(colorChooserButtonArgument);
themeLocal.setBaseColor(iLocal, colorChooserButtons.get(iLocal).getSelectedColor());
// Update the palette
int offset = iLocal * 3;
for (int j = 0; j < 3; j++) {
Component colorPaletteCell = colorPaletteTablePane.getRows().get(iLocal).get(j);
colorPaletteCell.getStyles().put(Style.backgroundColor, offset + j);
}
// Reload the sample part of the content (but not all the application),
// this means that the rest of the application always show original colors
reloadContent();
}
};
colorChooserButton.getColorChooserButtonSelectionListeners().add(colorChooserButtonSelectionListener);
SpinnerSelectionListener spinnerSelectionListener = new SpinnerSelectionListener() {
@Override
public void selectedItemChanged(Spinner spinner, Object previousSelectedItem) {
int red = ((Integer) redSpinner.getSelectedItem()).intValue();
int green = ((Integer) greenSpinner.getSelectedItem()).intValue();
int blue = ((Integer) blueSpinner.getSelectedItem()).intValue();
colorChooserButton.setSelectedColor(new Color(red, green, blue));
}
};
redSpinner.getSpinnerSelectionListeners().add(spinnerSelectionListener);
greenSpinner.getSpinnerSelectionListeners().add(spinnerSelectionListener);
blueSpinner.getSpinnerSelectionListeners().add(spinnerSelectionListener);
// Initialize the button color with the theme default
themeOriginalColors.add(theme.getBaseColor(i));
colorChooserButton.setSelectedColor(theme.getBaseColor(i));
}
copyToClipboardButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
copyToClipboard();
}
});
resetPaletteButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
resetPalette();
}
});
// Initialize content
reloadContent();
}
use of org.apache.pivot.wtk.Theme in project pivot by apache.
the class NumberRulerSkin method install.
@Override
public void install(Component component) {
super.install(component);
Theme theme = Theme.getTheme();
setFont(theme.getFont());
setColor(0);
setBackgroundColor(19);
markerSpacing = 5;
markerInsets = new Insets(0);
rowPadding = new Insets(0);
// Note: these aren't settable
majorDivision = 10;
minorDivision = 5;
// But these are
showMajorNumbers = true;
showMinorNumbers = false;
NumberRuler ruler = (NumberRuler) component;
ruler.getRulerListeners().add(this);
}
use of org.apache.pivot.wtk.Theme in project pivot by apache.
the class TextAreaSkin method install.
@Override
public void install(Component component) {
super.install(component);
Theme theme = currentTheme();
theme.setDefaultStyles(this);
TextArea textArea = (TextArea) component;
textArea.getTextAreaListeners().add(this);
textArea.getTextAreaContentListeners().add(this);
textArea.getTextAreaSelectionListeners().add(this);
textArea.setCursor(Cursor.TEXT);
}
use of org.apache.pivot.wtk.Theme in project pivot by apache.
the class RulerSkin method setBackgroundColor.
public final void setBackgroundColor(int backgroundColor) {
Theme theme = currentTheme();
setBackgroundColor(theme.getColor(backgroundColor));
}
use of org.apache.pivot.wtk.Theme in project pivot by apache.
the class RulerSkin method setColor.
public final void setColor(int color) {
Theme theme = currentTheme();
setColor(theme.getColor(color));
}
Aggregations