com.bric.swing.ColorPicker Java Examples
The following examples show how to use
com.bric.swing.ColorPicker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ColorPickerSliderUI.java From Pixelitor with GNU General Public License v3.0 | 6 votes |
public ColorPickerSliderUI(JSlider b, ColorPicker cp) { super(b); colorPicker = cp; cp.getColorPanel().addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { try { calculateGeometry(); } catch (Exception ex) { // can throw NullPointerException // when changing the look-and-feel } slider.repaint(); } }); }
Example #2
Source File: LayersEditor.java From nordpos with GNU General Public License v3.0 | 5 votes |
private void jColorChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jColorChooserActionPerformed ColorPicker picker = new ColorPicker(); picker.setColor(Color.WHITE); picker.setOpacityVisible(false); JOptionPane.showMessageDialog(null, picker, AppLocal.getIntString("dialog.ColorPicker"), JOptionPane.PLAIN_MESSAGE); Color newColor = picker.getColor(); String sColor = "0x" + Integer.toHexString(0x100 | newColor.getRed()).substring(1).toUpperCase() + Integer.toHexString(0x100 | newColor.getGreen()).substring(1).toUpperCase() + Integer.toHexString(0x100 | newColor.getBlue()).substring(1).toUpperCase(); m_jColor.setText(sColor); m_jColor.setBackground(new Color((int) Integer.decode(sColor))); }
Example #3
Source File: ColorPickerSliderUI.java From PyramidShader with GNU General Public License v3.0 | 5 votes |
public ColorPickerSliderUI(JSlider b,ColorPicker cp) { super(b); colorPicker = cp; cp.getColorPanel().addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { ColorPickerSliderUI.this.calculateGeometry(); slider.repaint(); } }); }
Example #4
Source File: ColorUtils.java From Pixelitor with GNU General Public License v3.0 | 5 votes |
public static void selectColorWithDialog(Window owner, String title, Color selectedColor, boolean allowTransparency, Consumer<Color> colorChangeListener) { Color prevColor = selectedColor; GlobalEvents.dialogOpened(title); Color color = ColorPicker.showDialog(owner, title, selectedColor, allowTransparency, colorChangeListener); GlobalEvents.dialogClosed(title); if (color == null) { // Cancel was pressed, reset the old color colorChangeListener.accept(prevColor); } }
Example #5
Source File: ColorPickerSliderUI.java From PyramidShader with GNU General Public License v3.0 | 4 votes |
@Override public synchronized void paintTrack(Graphics g) { int mode = colorPicker.getMode(); if(mode==ColorPicker.HUE || mode==ColorPicker.BRI || mode==ColorPicker.SAT) { float[] hsb = colorPicker.getHSB(); if(mode==ColorPicker.HUE) { for(int y = 0; y<trackRect.height; y++) { float hue = ((float)y)/((float)trackRect.height); intArray[y] = Color.HSBtoRGB( hue, 1, 1); } } else if(mode==ColorPicker.SAT) { for(int y = 0; y<trackRect.height; y++) { float sat = 1-((float)y)/((float)trackRect.height); intArray[y] = Color.HSBtoRGB( hsb[0], sat, hsb[2]); } } else { for(int y = 0; y<trackRect.height; y++) { float bri = 1-((float)y)/((float)trackRect.height); intArray[y] = Color.HSBtoRGB( hsb[0], hsb[1], bri); } } } else { int[] rgb = colorPicker.getRGB(); if(mode==ColorPicker.RED) { for(int y = 0; y<trackRect.height; y++) { int red = 255-(int)(y*255/trackRect.height+.49); intArray[y] = (red << 16)+(rgb[1] << 8)+(rgb[2]); } } else if(mode==ColorPicker.GREEN) { for(int y = 0; y<trackRect.height; y++) { int green = 255-(int)(y*255/trackRect.height+.49); intArray[y] = (rgb[0] << 16)+(green << 8)+(rgb[2]); } } else if(mode==ColorPicker.BLUE) { for(int y = 0; y<trackRect.height; y++) { int blue = 255-(int)(y*255/trackRect.height+.49); intArray[y] = (rgb[0] << 16)+(rgb[1] << 8)+(blue); } } } Graphics2D g2 = (Graphics2D)g; Rectangle r = new Rectangle(6, trackRect.y, 14, trackRect.height); if(slider.hasFocus()) { PlafPaintUtils.paintFocus(g2,r,3); } bi.getRaster().setDataElements(0,0,1,trackRect.height,intArray); TexturePaint p = new TexturePaint(bi,new Rectangle(0,trackRect.y,1,bi.getHeight())); g2.setPaint(p); g2.fillRect(r.x,r.y,r.width,r.height); PlafPaintUtils.drawBevel(g2, r); }
Example #6
Source File: ColorPickerSliderUI.java From Pixelitor with GNU General Public License v3.0 | 4 votes |
@Override public synchronized void paintTrack(Graphics g) { int mode = colorPicker.getMode(); if (mode == ColorPicker.HUE || mode == ColorPicker.BRI || mode == ColorPicker.SAT) { float[] hsb = colorPicker.getHSB(); if (mode == ColorPicker.HUE) { for (int y = 0; y < trackRect.height; y++) { float hue = ((float) y) / ((float) trackRect.height); intArray[y] = Color.HSBtoRGB(hue, 1, 1); } } else if (mode == ColorPicker.SAT) { for (int y = 0; y < trackRect.height; y++) { float sat = 1 - ((float) y) / ((float) trackRect.height); intArray[y] = Color.HSBtoRGB(hsb[0], sat, hsb[2]); } } else { for (int y = 0; y < trackRect.height; y++) { float bri = 1 - ((float) y) / ((float) trackRect.height); intArray[y] = Color.HSBtoRGB(hsb[0], hsb[1], bri); } } } else { int[] rgb = colorPicker.getRGB(); if (mode == ColorPicker.RED) { for (int y = 0; y < trackRect.height; y++) { int red = 255 - (int) (y * 255 / trackRect.height + 0.49); intArray[y] = (red << 16) + (rgb[1] << 8) + rgb[2]; } } else if (mode == ColorPicker.GREEN) { for (int y = 0; y < trackRect.height; y++) { int green = 255 - (int) (y * 255 / trackRect.height + 0.49); intArray[y] = (rgb[0] << 16) + (green << 8) + rgb[2]; } } else if (mode == ColorPicker.BLUE) { for (int y = 0; y < trackRect.height; y++) { int blue = 255 - (int) (y * 255 / trackRect.height + 0.49); intArray[y] = (rgb[0] << 16) + (rgb[1] << 8) + blue; } } } Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(6, trackRect.y, 14, trackRect.height); if (slider.hasFocus()) { PlafPaintUtils.paintFocus(g2, r, 3); } bi.getRaster().setDataElements(0, 0, 1, trackRect.height, intArray); TexturePaint p = new TexturePaint(bi, new Rectangle(0, trackRect.y, 1, bi.getHeight())); g2.setPaint(p); g2.fillRect(r.x, r.y, r.width, r.height); PlafPaintUtils.drawBevel(g2, r); }