[Patchanim-commit] SF.net SVN: patchanim: [225] trunk/patchanim/src/com/mebigfatguy/patchanim
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-02-24 02:28:30
|
Revision: 225
http://patchanim.svn.sourceforge.net/patchanim/?rev=225&view=rev
Author: dbrosius
Date: 2008-02-23 18:28:36 -0800 (Sat, 23 Feb 2008)
Log Message:
-----------
Stub in support for controlling transparency with patches
Modified Paths:
--------------
trunk/patchanim/src/com/mebigfatguy/patchanim/PatchAnimDocument.java
trunk/patchanim/src/com/mebigfatguy/patchanim/PatchColor.java
trunk/patchanim/src/com/mebigfatguy/patchanim/ShiftDirection.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java
trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd
trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl
trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java
trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java
trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java
trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties
trunk/patchanim/src/com/mebigfatguy/patchanim/surface/CombinedPatch.java
trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java
trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java
Added Paths:
-----------
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/PatchAnimDocument.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/PatchAnimDocument.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/PatchAnimDocument.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -33,6 +33,7 @@
private boolean dirty;
private int order;
+ private boolean useAlpha;
private List<CombinedPatch> patches;
private int width;
private int height;
@@ -43,8 +44,9 @@
/**
* constructs a new document for the New menu item
*/
- public PatchAnimDocument(int patchOrder) {
+ public PatchAnimDocument(int patchOrder, boolean alpha) {
order = patchOrder;
+ useAlpha = alpha;
patches = new ArrayList<CombinedPatch>();
CombinedPatch patch = new CombinedPatch(order, true);
patches.add(patch);
@@ -80,6 +82,14 @@
}
/**
+ * returns whether to use the alpha channel
+ * @return the alpha channel option flag
+ */
+ public boolean useAlpha() {
+ return useAlpha;
+ }
+
+ /**
* retrieves a list of all the bezier patches
* @return the list of all the bezier patches
*/
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/PatchColor.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/PatchColor.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/PatchColor.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -22,5 +22,6 @@
Red,
Green,
Blue,
+ Alpha,
Combined;
}
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/ShiftDirection.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/ShiftDirection.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/ShiftDirection.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -1,3 +1,21 @@
+/*
+ * 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;
import java.util.ResourceBundle;
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -97,14 +97,16 @@
}
private void initListeners() {
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
+ final PatchPanelMediator mediator = PatchPanelMediator.getMediator();
mediator.addActivePatchChangedListener(new ActivePatchChangedListener() {
public void activePatchChanged(ActivePatchChangedEvent apce) {
CombinedPatch currentPatch = apce.getActivePatch();
- coords = currentPatch.getPatch(color);
- if (coords != null) {
- setColorField(false);
- sample.recalcImage(color, currentPatch);
+ if ((color != PatchColor.Alpha) || mediator.getDocument().useAlpha()) {
+ coords = currentPatch.getPatch(color);
+ if (coords != null) {
+ setColorField(false);
+ sample.recalcImage(color, currentPatch);
+ }
}
}
});
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -83,7 +83,7 @@
cp.setLayout(new BorderLayout(4, 4));
JPatchAnimPanel patchPanel = new JPatchAnimPanel();
- document = new PatchAnimDocument(4);
+ document = new PatchAnimDocument(4, false);
documentLocation = null;
PatchPanelMediator mediator = PatchPanelMediator.getMediator();
mediator.setDocument(document);
@@ -185,24 +185,15 @@
}
}
- Integer choice = (Integer)JOptionPane.showInputDialog(JPatchAnimFrame.this,
- rb.getString(PatchAnimBundle.SETORDER),
- rb.getString(PatchAnimBundle.TITLE),
- JOptionPane.QUESTION_MESSAGE,
- new ImageIcon(JPatchAnimFrame.this.getIconImage()),
- new Object[] { Integer.valueOf(2),
- Integer.valueOf(3),
- Integer.valueOf(4),
- Integer.valueOf(5),
- Integer.valueOf(6),
- Integer.valueOf(7),
- Integer.valueOf(8),
- Integer.valueOf(9) },
- Integer.valueOf(4));
- if (choice == null)
- choice = Integer.valueOf(4);
+ NewDocumentDialog newDialog = new NewDocumentDialog();
+ newDialog.setModal(true);
+ newDialog.setLocationRelativeTo(JPatchAnimFrame.this);
+ newDialog.setVisible(true);
- document = new PatchAnimDocument(choice.intValue());
+ int order = newDialog.getOrder();
+ boolean useAlpha = newDialog.useAlpha();
+
+ document = new PatchAnimDocument(order, useAlpha);
documentLocation = null;
saveItem.setEnabled(false);
PatchPanelMediator mediator = PatchPanelMediator.getMediator();
@@ -229,7 +220,7 @@
load();
ResourceBundle rb = PatchAnimBundle.getBundle();
- String title = MessageFormat.format(rb.getString(PatchAnimBundle.NAMEDTITLE), documentLocation.getName());
+ String title = MessageFormat.format(rb.getString(PatchAnimBundle.NAMEDTITLE), documentLocation == null ? "" : documentLocation.getName());
setTitle(title);
} catch (IOException ioe) {
@@ -365,7 +356,7 @@
ResourceBundle rb = PatchAnimBundle.getBundle();
JOptionPane.showMessageDialog(JPatchAnimFrame.this, rb.getString(PatchAnimBundle.LOADFAILED));
documentLocation = null;
- document = new PatchAnimDocument(4);
+ document = new PatchAnimDocument(4, false);
} finally {
PatchPanelMediator mediator = PatchPanelMediator.getMediator();
mediator.setDocument(document);
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -31,6 +31,8 @@
private static final long serialVersionUID = 3030850111559417377L;
+ private SourcePatchesPanel sourcesPanel;
+
public JPatchAnimPanel() {
initComponents();
}
@@ -59,23 +61,9 @@
Utils.sizeUniformly(Utils.Sizing.Width, ctrl, listPanel );
- q = new JPanel();
- {
- q.setLayout(new BoxLayout(q, BoxLayout.X_AXIS));
- JColorControlPatchPanel redPatch = new JColorControlPatchPanel(PatchColor.Red);
- JColorControlPatchPanel greenPatch = new JColorControlPatchPanel(PatchColor.Green);
- JColorControlPatchPanel bluePatch = new JColorControlPatchPanel(PatchColor.Blue);
-
- q.add(Box.createHorizontalGlue());
- q.add(redPatch);
- q.add(Box.createHorizontalStrut(10));
- q.add(greenPatch);
- q.add(Box.createHorizontalStrut(10));
- q.add(bluePatch);
- q.add(Box.createHorizontalGlue());
- }
+ sourcesPanel = new SourcePatchesPanel();
- p.add(q, BorderLayout.CENTER);
+ p.add(sourcesPanel, BorderLayout.CENTER);
p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -79,6 +79,8 @@
rgb = Color.green;
else if (c == PatchColor.Blue)
rgb = Color.blue;
+ else if (c == PatchColor.Alpha)
+ rgb = Color.white;
else
rgb = null;
@@ -146,14 +148,16 @@
PatchAnimDocument doc = dce.getDocument();
oob = doc.getOutOfBoundsColor();
PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- recalcImage(color, mediator.getActivePatch());
+ if ((color != PatchColor.Alpha) || mediator.getDocument().useAlpha())
+ recalcImage(color, mediator.getActivePatch());
}
});
mediator.addSettingsChangedListener(new SettingsChangedListener() {
public void settingsChanged(SettingsChangedEvent sce) {
oob = sce.getDocument().getOutOfBoundsColor();
PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- recalcImage(color, mediator.getActivePatch());
+ if ((color != PatchColor.Alpha) || mediator.getDocument().useAlpha())
+ recalcImage(color, mediator.getActivePatch());
}
});
}
Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java (rev 0)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -0,0 +1,142 @@
+/*
+ * 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.BorderLayout;
+import java.awt.Container;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ResourceBundle;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import com.mebigfatguy.patchanim.main.PatchAnimBundle;
+
+public class NewDocumentDialog extends JDialog {
+
+ private static final long serialVersionUID = 6141957372893989399L;
+
+ private JComboBox orderCombo;
+ private JCheckBox useAlpha;
+ private JButton ok;
+ private JButton cancel;
+ private boolean isOk = false;
+
+ public NewDocumentDialog() {
+ initComponents();
+ initListeners();
+ }
+
+ private void initComponents() {
+ ResourceBundle rb = PatchAnimBundle.getBundle();
+ Container cp = getContentPane();
+ setTitle(rb.getString(PatchAnimBundle.NEWDOCUMENT));
+ cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
+ JLabel orderLabel = new JLabel(rb.getString(PatchAnimBundle.SETORDER));
+ orderCombo = new JComboBox(new Object[] { Integer.valueOf(2),
+ Integer.valueOf(3),
+ Integer.valueOf(4),
+ Integer.valueOf(5),
+ Integer.valueOf(6),
+ Integer.valueOf(7),
+ Integer.valueOf(8),
+ Integer.valueOf(9) });
+ orderCombo.setSelectedItem(Integer.valueOf(4));
+
+ JPanel p = new JPanel();
+ p.setLayout(new BorderLayout(8, 8));
+ p.add(orderLabel, BorderLayout.WEST);
+ p.add(orderCombo, BorderLayout.CENTER);
+ p.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10));
+ cp.add(p);
+
+ useAlpha = new JCheckBox(rb.getString(PatchAnimBundle.USEALPHA));
+ p = new JPanel();
+ p.setLayout(new BorderLayout(8, 8));
+ p.add(useAlpha, BorderLayout.CENTER);
+ p.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10));
+ cp.add(p);
+
+ p = new JPanel();
+ p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
+ p.add(Box.createHorizontalGlue());
+ ok = new JButton(rb.getString(PatchAnimBundle.OK));
+ p.add(ok);
+ p.add(Box.createHorizontalStrut(10));
+ cancel = new JButton(rb.getString(PatchAnimBundle.CANCEL));
+ p.add(cancel);
+ p.add(Box.createHorizontalGlue());
+ p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ cp.add(p);
+
+ Utils.sizeUniformly(Utils.Sizing.Width, orderCombo, useAlpha);
+ Utils.sizeUniformly(Utils.Sizing.Width, ok, cancel);
+ pack();
+ }
+
+ private void initListeners() {
+ ok.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ isOk = true;
+ dispose();
+ }
+ });
+
+ cancel.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ isOk = false;
+ dispose();
+ }
+ });
+
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent we) {
+ isOk = false;
+ dispose();
+ }
+ });
+ }
+
+ public boolean isOk() {
+ return isOk;
+ }
+
+ public int getOrder() {
+ if (isOk)
+ return ((Integer)orderCombo.getSelectedItem()).intValue();
+ return 4;
+ }
+
+ public boolean useAlpha() {
+ if (isOk)
+ return useAlpha.isSelected();
+ return false;
+ }
+}
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -47,14 +47,18 @@
return mediator;
}
public void addDocumentChangedListener(DocumentChangedListener dcl) {
- dclisteners.add(dcl);
+ synchronized(dclisteners) {
+ dclisteners.add(dcl);
+ }
}
public void setDocument(PatchAnimDocument doc) {
document = doc;
DocumentChangedEvent dce = new DocumentChangedEvent(this, doc);
- for (DocumentChangedListener dcl : dclisteners) {
- dcl.documentChanged(dce);
+ synchronized(dclisteners) {
+ for (DocumentChangedListener dcl : dclisteners) {
+ dcl.documentChanged(dce);
+ }
}
}
Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java (rev 0)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -0,0 +1,90 @@
+/*
+ * 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.Container;
+
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import com.mebigfatguy.patchanim.PatchColor;
+import com.mebigfatguy.patchanim.gui.events.DocumentChangedEvent;
+import com.mebigfatguy.patchanim.gui.events.DocumentChangedListener;
+
+public class SourcePatchesPanel extends JPanel {
+
+ private static final long serialVersionUID = 4186927445084750958L;
+
+ private boolean useAlpha;
+ JColorControlPatchPanel redPatch;
+ JColorControlPatchPanel greenPatch;
+ JColorControlPatchPanel bluePatch;
+ JColorControlPatchPanel alphaPatch;
+
+
+ public SourcePatchesPanel() {
+ useAlpha = false;
+
+ redPatch = new JColorControlPatchPanel(PatchColor.Red);
+ greenPatch = new JColorControlPatchPanel(PatchColor.Green);
+ bluePatch = new JColorControlPatchPanel(PatchColor.Blue);
+ alphaPatch = new JColorControlPatchPanel(PatchColor.Alpha);
+
+ rebuild(useAlpha);
+
+ PatchPanelMediator mediator = PatchPanelMediator.getMediator();
+ mediator.addDocumentChangedListener(new DocumentChangedListener() {
+ public void documentChanged(DocumentChangedEvent dce) {
+ rebuild(dce.getDocument().useAlpha());
+ }
+ });
+ }
+
+ public void rebuild(final boolean useAlpha) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ Container c = SourcePatchesPanel.this.getParent();
+ if (c != null)
+ c.invalidate();
+ removeAll();
+ setLayout(new BoxLayout(SourcePatchesPanel.this, BoxLayout.X_AXIS));
+ add(Box.createHorizontalGlue());
+ add(redPatch);
+ add(Box.createHorizontalStrut(10));
+ add(greenPatch);
+ add(Box.createHorizontalStrut(10));
+ add(bluePatch);
+ if (useAlpha) {
+ add(Box.createHorizontalStrut(10));
+ add(alphaPatch);
+ }
+ add(Box.createHorizontalGlue());
+ invalidate();
+ revalidate();
+ if (c != null) {
+ c.invalidate();
+ c.repaint();
+ }
+
+ }
+ });
+ }
+}
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd 2008-02-24 02:28:36 UTC (rev 225)
@@ -27,6 +27,7 @@
<xsd:attribute name="version" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="SettingsClass">
+ <xsd:attribute name="alpha" type="xsd:boolean" default="false"/>
<xsd:attribute name="animationType" type="AnimationTypeClass" use="required"/>
<xsd:attribute name="height" type="xsd:integer" use="required"/>
<xsd:attribute name="order" type="xsd:positiveInteger" default="4"/>
@@ -50,9 +51,10 @@
</xsd:simpleType>
<xsd:simpleType name="ColorClass">
<xsd:restriction base="xsd:string">
+ <xsd:enumeration value="Red"/>
<xsd:enumeration value="Green"/>
<xsd:enumeration value="Blue"/>
- <xsd:enumeration value="Red"/>
+ <xsd:enumeration value="Alpha"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="CoordinateClass">
@@ -68,7 +70,7 @@
</xsd:complexType>
<xsd:complexType name="CombinedPatchClass">
<xsd:sequence>
- <xsd:element maxOccurs="3" minOccurs="3" name="Patch" type="PatchClass"/>
+ <xsd:element maxOccurs="4" minOccurs="3" name="Patch" type="PatchClass"/>
</xsd:sequence>
<xsd:attribute name="name" type="NameClass" use="required"/>
</xsd:complexType>
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl 2008-02-24 02:28:36 UTC (rev 225)
@@ -40,6 +40,9 @@
<xsl:attribute name="order">
<xsl:value-of select="pae:getOrder($ext)"/>
</xsl:attribute>
+ <xsl:attribute name="alpha">
+ <xsl:value-of select="pae:useAlpha($ext)"/>
+ </xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="pae:getWidth($ext)"/>
</xsl:attribute>
@@ -108,6 +111,23 @@
</Coordinate>
</xsl:for-each>
</Patch>
+ <xsl:if test="pae:useAlpha($ext)='true'">
+ <Patch color="Alpha">
+ <xsl:for-each select="pae:getCoordinates($ext)">
+ <Coordinate>
+ <xsl:attribute name="x">
+ <xsl:value-of select="pae:getX($ext, 'Alpha', $patchIndex, .)"/>
+ </xsl:attribute>
+ <xsl:attribute name="y">
+ <xsl:value-of select="pae:getY($ext, 'Alpha', $patchIndex, .)"/>
+ </xsl:attribute>
+ <xsl:attribute name="color">
+ <xsl:value-of select="pae:getColor($ext, 'Alpha', $patchIndex, .)"/>
+ </xsl:attribute>
+ </Coordinate>
+ </xsl:for-each>
+ </Patch>
+ </xsl:if>
</CombinedPatch>
</xsl:for-each>
</Patches>
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -83,6 +83,10 @@
return String.valueOf(paDoc.getTweenCount());
}
+ public String useAlpha(@SuppressWarnings("unused") ExpressionContext context) {
+ return String.valueOf(paDoc.useAlpha());
+ }
+
public NodeList getPatches(@SuppressWarnings("unused") ExpressionContext context) {
return new NodeList() {
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -112,6 +112,7 @@
static class PatchAnimDocContentHandler extends DefaultHandler {
private static final String SETTINGS = "Settings";
private static final String ORDER = "order";
+ private static final String ALPHA = "alpha";
private static final String WIDTH = "width";
private static final String HEIGHT = "height";
private static final String ANIMATIONTYPE = "animationType";
@@ -135,7 +136,8 @@
public void startElement(String uri, String localName, String qName, Attributes atts) {
if (SETTINGS.equals(localName)) {
int order = Integer.parseInt(atts.getValue(ORDER));
- doc = new PatchAnimDocument(order);
+ boolean alpha = Boolean.parseBoolean(atts.getValue(ALPHA));
+ doc = new PatchAnimDocument(order, alpha);
doc.getPatches().clear();
doc.setWidth(Integer.parseInt(atts.getValue(WIDTH)));
doc.setHeight(Integer.parseInt(atts.getValue(HEIGHT)));
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -47,7 +47,11 @@
public static final String EXPORTINGFILE = "patchanim.exportfile";
public static final String QUIT = "patchanim.quit";
public static final String CONTROLS = "patchanim.control";
+ public static final String NEWDOCUMENT = "patchanim.newdocument";
public static final String SETORDER = "patchanim.setorder";
+ public static final String USEALPHA = "patchanim.usealpha";
+ public static final String OK = "patchanim.ok";
+ public static final String CANCEL = "patchanim.cancel";
public static final String PATCHES = "patchanim.patches";
public static final String WIDTH = "patchanim.width";
public static final String WIDTH_TT = "patchanim.tooltip.width";
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-24 02:28:36 UTC (rev 225)
@@ -40,7 +40,11 @@
patchanim.exportfile = Exporting Animation
patchanim.quit = Quit
patchanim.control = Controls
+patchanim.newdocument = New PatchAnim document settings
patchanim.setorder = Set the order of the patches to
+patchanim.usealpha = Use Alpha channel (transparency)
+patchanim.ok = OK
+patchanim.cancel = Cancel
patchanim.patches = Patches
patchanim.width = Width
patchanim.tooltip.width = The width of the exported animation
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/CombinedPatch.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/CombinedPatch.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/CombinedPatch.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -24,6 +24,7 @@
import java.util.ResourceBundle;
import com.mebigfatguy.patchanim.PatchColor;
+import com.mebigfatguy.patchanim.gui.PatchPanelMediator;
import com.mebigfatguy.patchanim.main.PatchAnimBundle;
public class CombinedPatch implements Serializable, Cloneable {
@@ -37,19 +38,22 @@
patches.put(PatchColor.Red, PatchCoords.buildRandomPatch(order));
patches.put(PatchColor.Green, PatchCoords.buildRandomPatch(order));
patches.put(PatchColor.Blue, PatchCoords.buildRandomPatch(order));
+ patches.put(PatchColor.Alpha, PatchCoords.buildFullColorPatch(order));
} else {
patches.put(PatchColor.Red, new PatchCoords(order));
patches.put(PatchColor.Green, new PatchCoords(order));
patches.put(PatchColor.Blue, new PatchCoords(order));
+ patches.put(PatchColor.Alpha, new PatchCoords(order));
}
ResourceBundle rb = PatchAnimBundle.getBundle();
name = rb.getString(PatchAnimBundle.DEFAULTPATCHNAME);
}
- public CombinedPatch(PatchCoords redPatch, PatchCoords greenPatch, PatchCoords bluePatch) {
+ public CombinedPatch(PatchCoords redPatch, PatchCoords greenPatch, PatchCoords bluePatch, PatchCoords alphaPatch) {
patches.put(PatchColor.Red, redPatch);
patches.put(PatchColor.Green, greenPatch);
patches.put(PatchColor.Blue, bluePatch);
+ patches.put(PatchColor.Alpha, alphaPatch);
}
@Override
@@ -82,6 +86,14 @@
PatchCoords eBlueCoords = endPatch.getPatch(PatchColor.Blue);
tweenPatch.setPatch(PatchColor.Blue, PatchCoords.tween(sBlueCoords, eBlueCoords, frac));
}
+
+ PatchPanelMediator mediator = PatchPanelMediator.getMediator();
+ if (mediator.getDocument().useAlpha())
+ {
+ PatchCoords sAlphaCoords = startPatch.getPatch(PatchColor.Alpha);
+ PatchCoords eAlphaCoords = endPatch.getPatch(PatchColor.Alpha);
+ tweenPatch.setPatch(PatchColor.Alpha, PatchCoords.tween(sAlphaCoords, eAlphaCoords, frac));
+ }
return tweenPatch;
}
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -39,6 +39,16 @@
return new PatchCoords(patchOrder, coords);
}
+ public static PatchCoords buildFullColorPatch(int patchOrder) {
+ Coordinate[][] coords = new Coordinate[patchOrder][patchOrder];
+ for (int u = 0; u < patchOrder; u++) {
+ for (int v = 0; v < patchOrder; v++) {
+ coords[u][v] = new Coordinate((u * 100.0) / (patchOrder - 1), (v * 100.0) / (patchOrder - 1), 255);
+ }
+ }
+ return new PatchCoords(patchOrder, coords);
+ }
+
public PatchCoords(int patchOrder) {
order = patchOrder;
coords = new Coordinate[patchOrder][patchOrder];
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-24 02:25:51 UTC (rev 224)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-24 02:28:36 UTC (rev 225)
@@ -97,6 +97,9 @@
int pixel = 0;
PatchCoords coords = patch.getPatch(color);
+ if (coords.getCoordinate(0, 0) == null)
+ return;
+
int order = coords.getOrder();
double u;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|