public ColorPopupMenuButton(AppD app, Dimension iconSize, int colorSetType, boolean hasSlider) { super( app, createDummyIcons(iconSize), -1, 9, iconSize, geogebra.common.gui.util.SelectionTable.MODE_ICON); this.app = app; this.iconSize = iconSize; this.colorSetType = colorSetType; this.hasSlider = hasSlider; colorSet = getColorArray(colorSetType); defaultColor = colorSet[0]; lookupMap = new HashMap<Color, Integer>(); for (int i = 0; i < colorSet.length; i++) { lookupMap.put(geogebra.awt.GColorD.getAwtColor(colorSet[i]), i); } setToolTipArray(getToolTipArray()); getMyTable().setUseColorSwatchBorder(true); getMySlider().setMinimum(0); getMySlider().setMaximum(100); getMySlider().setMajorTickSpacing(25); getMySlider().setMinorTickSpacing(5); setSliderValue(100); getMySlider().setVisible(hasSlider); updateColorTable(); addActionListener(this); }
public void setDefaultColor(float alpha, geogebra.common.awt.GColor gc) { defaultColor = gc; if (gc != null) this.setIcon( GeoGebraIcon.createColorSwatchIcon( alpha, iconSize, geogebra.awt.GColorD.getAwtColor(gc), null)); else this.setIcon(GeoGebraIcon.createNullSymbolIcon(iconSize.width, iconSize.height)); }
private void applyTextColor(ArrayList<GeoElement> geos) { Color color = geogebra.awt.GColorD.getAwtColor(btnTextColor.getSelectedColor()); for (int i = 0; i < geos.size(); i++) { GeoElement geo = geos.get(i); if (geo instanceof GeoCasCell) { ((GeoCasCell) geo).setFontColor(new geogebra.awt.GColorD(color)); geo.updateRepaint(); needUndo = true; } } }
@Override public ImageIcon getButtonIcon() { ImageIcon icon = super.getButtonIcon(); if (icon == null && this.hasSlider) { icon = GeoGebraIcon.createColorSwatchIcon( getSliderValue() / 100f, iconSize, geogebra.awt.GColorD.getAwtColor(defaultColor), null); } return icon; }
private static ImageIcon[] getColorSwatchIcons( geogebra.common.awt.GColor[] colorArray, float alpha, Dimension iconSize, int colorSetType) { ImageIcon[] a = new ImageIcon[colorArray.length]; for (int i = 0; i < colorArray.length; i++) if (colorArray[i] != null) { a[i] = GeoGebraIcon.createColorSwatchIcon( alpha, iconSize, geogebra.awt.GColorD.getAwtColor(colorArray[i]), null); } else { a[i] = GeoGebraIcon.createNullSymbolIcon(iconSize.width, iconSize.height); } return a; }