[Patchanim-commit] SF.net SVN: patchanim: [25] trunk/patchanim/src/com/mebigfatguy/patchanim/ gui/J
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-01-26 07:16:34
|
Revision: 25 http://patchanim.svn.sourceforge.net/patchanim/?rev=25&view=rev Author: dbrosius Date: 2008-01-25 23:16:38 -0800 (Fri, 25 Jan 2008) Log Message: ----------- Removed file/folder Removed Paths: ------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JCoordControl.java Deleted: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JCoordControl.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JCoordControl.java 2008-01-26 07:15:09 UTC (rev 24) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JCoordControl.java 2008-01-26 07:16:38 UTC (rev 25) @@ -1,154 +0,0 @@ -/* - * patchanim - A bezier surface patch color blend gif builder - * Copyright (C) 2008 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.patchanim.gui; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.image.BufferedImage; -import java.awt.image.DataBuffer; -import java.awt.image.IndexColorModel; -import java.awt.image.WritableRaster; - -import javax.swing.JComponent; - -public class JCoordControl extends JComponent { - - private Color color; - private BufferedImage image; - private int lowVal; - private int hiVal; - private int firstCurVal; - private int secondCurVal; - private int[] xs = new int[3]; - private int[] ys = new int[3]; - - public JCoordControl(Color c) - { - color = c; - - byte[] r = new byte[256]; - byte[] g = new byte[256]; - byte[] b = new byte[256]; - - for (int i = 0; i < 256; i++) { - r[i] = (byte)((i * color.getRed()) / 255); - g[i] = (byte)((i * color.getGreen()) / 255); - b[i] = (byte)((i * color.getBlue()) / 255); - } - IndexColorModel icm = new IndexColorModel(8, 256, r, g, b); - - image = new BufferedImage(256, 1, BufferedImage.TYPE_BYTE_INDEXED, icm); - WritableRaster raster = image.getRaster(); - DataBuffer db = raster.getDataBuffer(); - for (int i = 0; i < 256; i++) { - db.setElem(i, i); - } - - Dimension d = new Dimension(100, 5); - setMinimumSize(d); - d = new Dimension(256, 20); - setPreferredSize(d); - lowVal = 0; - hiVal = 255; - firstCurVal = 255; - secondCurVal = 255; - - initListeners(); - setEnabled(true); - } - - public void initListeners() { - addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent me) { - if (inThumb()) { - - } else { - - } - } - }); - } - - public boolean inThumb() { - return false; - } - - public void setMinValue(int min) { - lowVal = min; - } - - public void setMaxValue(int max) { - hiVal = max; - } - - public void setFirstCurValue(int cur) { - firstCurVal = cur; - } - public void setSecondCurValue(int cur) { - secondCurVal = cur; - } - - @Override - public void paint(Graphics g) { - Color saveColor = g.getColor(); - try { - Rectangle bounds = getBounds(); - - g.drawImage(image, 0, 0, bounds.width, bounds.height, 0, 0, 256, 1, null); - g.setColor(Color.BLACK); - g.drawRect(0, 0, bounds.width, bounds.height); - - int pt = calcPt(firstCurVal, bounds); - xs[0] = Math.max(pt - 10, 1); - xs[1] = pt; - xs[2] = Math.min(pt + 10, bounds.width - 1); - - ys[0] = 0; - ys[1] = (bounds.height >> 1) - 2; - ys[2] = ys[0]; - g.setColor(Color.YELLOW); - g.fillPolygon(xs, ys, 3); - g.setColor(Color.BLACK); - g.drawPolygon(xs, ys, 3); - - pt = calcPt(secondCurVal, bounds); - ys[0] = bounds.height; - ys[1] = (bounds.height >> 1) + 2; - ys[2] = ys[0]; - g.setColor(Color.YELLOW); - g.fillPolygon(xs, ys, 3); - g.setColor(Color.BLACK); - g.drawPolygon(xs, ys, 3); - - - } finally { - g.setColor(saveColor); - } - } - - private int calcPt(int val, Rectangle bounds) { - double frac = ((double)(val - lowVal)) / ((double)(hiVal - lowVal)); - return (int)(bounds.width * frac + 0.49); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |