[tuxdroid-svn] r1411 - in software_suite_v2/software/tools: . attitunesStudio attitunesStudio/trunk
Status: Beta
Brought to you by:
ks156
Author: remi Date: 2008-07-29 10:07:47 +0200 (Tue, 29 Jul 2008) New Revision: 1411 Added: software_suite_v2/software/tools/attitunesStudio/ software_suite_v2/software/tools/attitunesStudio/branches/ software_suite_v2/software/tools/attitunesStudio/tags/ software_suite_v2/software/tools/attitunesStudio/trunk/ software_suite_v2/software/tools/attitunesStudio/trunk/.classpath software_suite_v2/software/tools/attitunesStudio/trunk/.project software_suite_v2/software/tools/attitunesStudio/trunk/images/ software_suite_v2/software/tools/attitunesStudio/trunk/images/TTS.png software_suite_v2/software/tools/attitunesStudio/trunk/images/Thumbs.db software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton1Enable.png software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton1Pressed.png software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton2Enable.png software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton2Pressed.PNG software_suite_v2/software/tools/attitunesStudio/trunk/images/background.png software_suite_v2/software/tools/attitunesStudio/trunk/images/leds.png software_suite_v2/software/tools/attitunesStudio/trunk/images/mouth+eyes.png software_suite_v2/software/tools/attitunesStudio/trunk/images/sound.png software_suite_v2/software/tools/attitunesStudio/trunk/images/spinning.png software_suite_v2/software/tools/attitunesStudio/trunk/images/wings.png software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomFullButton.png software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomMinusButton.png software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomPlusButton.png software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomPressedButton.png software_suite_v2/software/tools/attitunesStudio/trunk/src/ software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/AnchorConstraint.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/AnchorLayout.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ATTConfig.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ATTMisc.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlock.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlockContainer.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTXmlParser.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/vector/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/vector/ATTAreaVector.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/vector/ATTPointVector.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/vector/ATTTlvVector.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTSButton.java software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTScrollbar.java software_suite_v2/software/tools/attitunesStudio/trunk/src/main.java Log: * added "attitunesStudio" project Added: software_suite_v2/software/tools/attitunesStudio/trunk/.classpath =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/.classpath (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/.classpath 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="images"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: software_suite_v2/software/tools/attitunesStudio/trunk/.project =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/.project (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/.project 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>attitunes_studio</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/TTS.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/TTS.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/Thumbs.db =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/Thumbs.db ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton1Enable.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton1Enable.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton1Pressed.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton1Pressed.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton2Enable.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton2Enable.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton2Pressed.PNG =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/actionButton2Pressed.PNG ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/background.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/background.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/leds.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/leds.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/mouth+eyes.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/mouth+eyes.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/sound.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/sound.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/spinning.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/spinning.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/wings.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/wings.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomFullButton.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomFullButton.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomMinusButton.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomMinusButton.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomPlusButton.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomPlusButton.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomPressedButton.png =================================================================== (Binary files differ) Property changes on: software_suite_v2/software/tools/attitunesStudio/trunk/images/zoomPressedButton.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,360 @@ + +import com.cloudgarden.layout.AnchorConstraint; +import com.cloudgarden.layout.AnchorLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.Color; +import javax.swing.BoxLayout; +import javax.swing.WindowConstants; +import com.tuxisalive.attitunes.*; +import com.tuxisalive.attitunes.block.ATTBlock; +import com.tuxisalive.attitunes.block.ATTBlockContainer; +import com.tuxisalive.attitunes.visual.ATTBlockViewer; +import com.tuxisalive.attitunes.visual.ATTSButton; + +/** + * + * @author R Jocaille + * + */ +public class MainFrame extends javax.swing.JFrame +{ + private static final long serialVersionUID = 724080299924475945L; + + private ATTBlockViewer attBlockViewer; + + private ATTSButton zoomPlusButton; + private ATTSButton zoomMinusButton; + private ATTSButton zoomFullButton; + private ATTSButton createButton; + private ATTSButton deleteButton; + private ATTSButton copyButton; + private ATTSButton pastButton; + private ATTSButton playButton; + private ATTSButton stopButton; + + /** + * MainFrame constructor + */ + public MainFrame() + { + super(); + initGUI(); + this.setTitle("Attitunes studio"); + } + + /* + * Create the GUI + */ + private void initGUI() + { + try + { + /* Add a layout to the frame */ + BoxLayout thisLayout = new BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS); + getContentPane().setLayout(thisLayout); + + /* Close window */ + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent evt) { + thisWindowClosing(evt); + } + }); + + /* Main viewer */ + attBlockViewer = new ATTBlockViewer(640, 300); + AnchorLayout mainViewerLayout = new AnchorLayout(); + attBlockViewer.setLayout(mainViewerLayout); + getContentPane().add(attBlockViewer); + attBlockViewer.loadImages("/"); + attBlockViewer.events.register(ATTConfig.EVENT_POSITION_CHANGED, this, "onPositionChanged"); + attBlockViewer.events.register(ATTConfig.EVENT_LENGTH_CHANGED, this, "onLengthChanged"); + attBlockViewer.events.register(ATTConfig.EVENT_ZOOM_CHANGED, this, "onZoomChanged"); + attBlockViewer.events.register(ATTConfig.EVENT_SCROLLBAR_DRAG_STARTED, this, "onScrollbarDragStarted"); + attBlockViewer.events.register(ATTConfig.EVENT_SCROLLBAR_DRAGGING, this, "onScrollbarDragging"); + attBlockViewer.events.register(ATTConfig.EVENT_SCROLLBAR_DRAG_STOPPED, this, "onScrollbarDragStopped"); + attBlockViewer.events.register(ATTConfig.EVENT_ROW_SELECTED, this, "onRowSelected"); + attBlockViewer.events.register(ATTConfig.EVENT_BLOCK_SELECTED, this, "onBlockSelected"); + attBlockViewer.events.register(ATTConfig.EVENT_BLOCK_DRAG_STARTED, this, "onBlockDragStarted"); + attBlockViewer.events.register(ATTConfig.EVENT_BLOCK_DRAGGING, this, "onBlockDragging"); + attBlockViewer.events.register(ATTConfig.EVENT_BLOCK_DRAG_STOPPED, this, "onBlockDragStopped"); + + /* Load a file */ + attBlockViewer.loadAttitune("C:/Others/Files/attitunes/aero.att"); + + /* Zoom plus button */ + zoomPlusButton = new ATTSButton("/zoomPlusButton.png"); + zoomPlusButton.setPressedIcon("/zoomPressedButton.png"); + zoomPlusButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onZoomPlusButtonPressed(evt); + } + }); + attBlockViewer.add(zoomPlusButton, new AnchorConstraint(520, 270)); + + /* Zoom minus button */ + zoomMinusButton = new ATTSButton("/zoomMinusButton.png"); + zoomMinusButton.setPressedIcon("/zoomPressedButton.png"); + zoomMinusButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onZoomMinusButtonPressed(evt); + } + }); + attBlockViewer.add(zoomMinusButton, new AnchorConstraint(550, 270)); + + /* Zoom full button */ + zoomFullButton = new ATTSButton("/zoomFullButton.png"); + zoomFullButton.setPressedIcon("/zoomPressedButton.png"); + zoomFullButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onZoomFullButtonPressed(evt); + } + }); + attBlockViewer.add(zoomFullButton, new AnchorConstraint(580, 270)); + + /* Create button */ + createButton = new ATTSButton("Create", Color.WHITE, "/actionButton1Enable.png"); + createButton.setPressedIcon("/actionButton1Pressed.png"); + createButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onCreateButtonPressed(evt); + } + }); + attBlockViewer.add(createButton, new AnchorConstraint(110, 271)); + + /* Delete button */ + deleteButton = new ATTSButton("Delete", Color.WHITE, "/actionButton1Enable.png"); + deleteButton.setPressedIcon("/actionButton1Pressed.png"); + deleteButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onDeleteButtonPressed(evt); + } + }); + attBlockViewer.add(deleteButton, new AnchorConstraint(200, 271)); + + /* Copy button */ + copyButton = new ATTSButton("Copy", Color.WHITE, "/actionButton1Enable.png"); + copyButton.setPressedIcon("/actionButton1Pressed.png"); + copyButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onCopyButtonPressed(evt); + } + }); + attBlockViewer.add(copyButton, new AnchorConstraint(290, 271)); + + /* Past button */ + pastButton = new ATTSButton("Past", Color.WHITE, "/actionButton1Enable.png"); + pastButton.setPressedIcon("/actionButton1Pressed.png"); + pastButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onPastButtonPressed(evt); + } + }); + attBlockViewer.add(pastButton, new AnchorConstraint(380, 271)); + + /* Play button */ + playButton = new ATTSButton("Play", Color.BLACK, "/actionButton2Enable.png"); + playButton.setPressedIcon("/actionButton2Pressed.png"); + playButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onPlayButtonPressed(evt); + } + }); + attBlockViewer.add(playButton, new AnchorConstraint(10, 248)); + + /* Stop button */ + stopButton = new ATTSButton("Stop", Color.BLACK, "/actionButton2Enable.png"); + stopButton.setPressedIcon("/actionButton2Pressed.png"); + stopButton.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) + { + onStopButtonPressed(evt); + } + }); + attBlockViewer.add(stopButton, new AnchorConstraint(10, 273)); + + /* Pack the components and set the frame size */ + pack(); + setSize(648, 400); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /* ------------------------------------------------------------------------ + * Window events + * --------------------------------------------------------------------- */ + + /* + * Event on window closing + */ + private void thisWindowClosing(WindowEvent evt) + { + attBlockViewer.destroy(); + } + + /* ------------------------------------------------------------------------ + * Blocks viewer events + * --------------------------------------------------------------------- */ + + /* + * Event when the cursor position was changed + */ + public void onPositionChanged(Double newPosition) + { + } + + /* + * Event when the length of the scene was changed + */ + public void onLengthChanged(Double newLength) + { + } + + /* + * Event when the zoom was changed + */ + public void onZoomChanged(Integer newZoomFactor) + { + } + + /* + * Event when the scrollbar dragging was started + */ + public void onScrollbarDragStarted() + { + } + + /* + * Event when the scrollbar is dragged + */ + public void onScrollbarDragging() + { + } + + /* + * Event when the scrollbar dragging was stopped + */ + public void onScrollbarDragStopped() + { + } + + /* + * Event when a new row was selected + */ + public void onRowSelected(Integer rowIdx, ATTBlockContainer blockContainer) + { + } + + /* + * Event when a new block was selected + */ + public void onBlockSelected(ATTBlock block) + { + System.out.println(block.getFunctionParams()); + } + + /* + * Event when the block dragging was started + */ + public void onBlockDragStarted(ATTBlock block) + { + } + + /* + * Event when the block is dragged + */ + public void onBlockDragging(ATTBlock block, Double timeIdx) + { + } + + /* + * Event when the block dragging was stopped + */ + public void onBlockDragStopped(ATTBlock block) + { + } + + /* ------------------------------------------------------------------------ + * Blocks buttons events + * --------------------------------------------------------------------- */ + + /* + * Zoom plus button pressed + */ + public void onZoomPlusButtonPressed(MouseEvent evt) + { + attBlockViewer.setZoomFactor(attBlockViewer.getZoomFactor() + 1); + } + + /* + * Zoom minus button pressed + */ + public void onZoomMinusButtonPressed(MouseEvent evt) + { + attBlockViewer.setZoomFactor(attBlockViewer.getZoomFactor() - 1); + } + + /* + * Zoom full button pressed + */ + public void onZoomFullButtonPressed(MouseEvent evt) + { + attBlockViewer.setZoomFactor(1); + } + + /* + * Create button pressed + */ + public void onCreateButtonPressed(MouseEvent evt) + { + } + + /* + * Delete button pressed + */ + public void onDeleteButtonPressed(MouseEvent evt) + { + } + + /* + * Copy button pressed + */ + public void onCopyButtonPressed(MouseEvent evt) + { + } + + /* + * Past button pressed + */ + public void onPastButtonPressed(MouseEvent evt) + { + } + + /* + * Play button pressed + */ + public void onPlayButtonPressed(MouseEvent evt) + { + } + + /* + * Stop button pressed + */ + public void onStopButtonPressed(MouseEvent evt) + { + } +} Added: software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/AnchorConstraint.java =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/AnchorConstraint.java (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/AnchorConstraint.java 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,85 @@ +/* + */ +package com.cloudgarden.layout; + +/** + * Used by both AnchorLayout (SWT) and AnchorLayoutManager (Swing) + */ +public class AnchorConstraint { + + /** + * Meaning: This side is not anchored. + */ + public static final int ANCHOR_NONE = 0; + + /** + * (Relative anchor) Meaning: This side is anchored so that it always + * occurs a fixed fraction of + * the distance along it's parent's side. The position is calculated by + * the formula " position = (parent side)*(value)/1000 " so for + * instance if top=100 and topType == ANCHOR_REL then the + * value of y for this side would be (parent height)*top/1000. + */ + public static final int ANCHOR_REL = 1; + + /** + * (Absolute anchor) Meaning: This side is anchored a fixed distance + * in pixels (given by the value for this side) from it's parent's respective side. + * For instance, if bottomType == ANCHOR_ABS and bottom = 100 then the + * bottom side of this component will remain fixed 100 pixels from + * the bottom side of it's parent container. + */ + public static final int ANCHOR_ABS = 2; + + public int top; + public int bottom; + public int left; + public int right; + public int topType; + public int bottomType; + public int rightType; + public int leftType; + + public AnchorConstraint() { + this(0, 0, 0, 0, ANCHOR_NONE, ANCHOR_NONE, ANCHOR_NONE, ANCHOR_NONE); + } + + /** + * Creates an AnchorConstraint. + * @param top - value (relative or absolute) for top side + * @param right - like 'top' but for right side + * @param bottom - like 'top' but for bottom side + * @param left - like 'top' but for left side + * @param topType - either ANCHOR_ABS, ANCHOR_REL or ANCHOR_NONE + * to indicate whether the 'top' parameter is an absolute value (in pixels) or + * a fractional value (in 1/1000 ths) of the height of this component's parent, + * denoting where the anchor will be applied (if at all). + * @param rightType - like 'topType' but for right side + * @param bottomType - like 'topType' but for bottom side + * @param leftType - like 'topType' but for left side + */ + public AnchorConstraint( + int top, + int right, + int bottom, + int left, + int topType, + int rightType, + int bottomType, + int leftType) { + this.top = top; + this.bottom = bottom; + this.left = left; + this.right = right; + this.topType = topType; + this.rightType = rightType; + this.bottomType = bottomType; + this.leftType = leftType; + } + + public AnchorConstraint(int left, int top) + { + this(top, 0, 0, left, ANCHOR_ABS, ANCHOR_NONE, ANCHOR_NONE, ANCHOR_ABS); + } + +} Added: software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/AnchorLayout.java =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/AnchorLayout.java (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/cloudgarden/layout/AnchorLayout.java 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,255 @@ +/* + */ +package com.cloudgarden.layout; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.LayoutManager2; +import java.awt.Rectangle; +import java.util.HashMap; + +/** + * Lays out components, using a combination of their "bounds" property + * and their AnchorConstraints layout constraint objects. + * <P> + * Sides of the components can be anchored either absolutely (eg, if the + * right side is anchored absolutely then it will always be a fixed number + * of pixels from the right side of it's parent container) or relatively (ie, + * if any side is anchored relatively then it will always occur a fixed + * fraction of the way along it's parent's side). Or they can be not anchored, + * at all in which case they will occur at places determined by their + * component's "bounds" property and the anchoring of the component's + * other sides. + */ +public class AnchorLayout implements LayoutManager2 { + + private int preferredWidth, preferredHeight, minHeight, minWidth; + private HashMap constraintMap = new HashMap(); + private boolean sizesCalculated = false; + private Container container; + + public AnchorLayout() { + super(); + } + + void initialize(Container parent) { + if (sizesCalculated) + return; + Component[] children = parent.getComponents(); + preferredWidth = 10000; + preferredHeight = 10000; + minWidth = 0; + minHeight = 0; + Rectangle pb = parent.getBounds(); + for (int i = 0; i < children.length; i++) { + Component child = children[i]; + if (child != null) { + Object ld = constraintMap.get(child); + Rectangle b = child.getBounds(); + Dimension pref = child.getPreferredSize(); + Dimension min = child.getMaximumSize(); + if (pref == null) + pref = child.getSize(); + if (min == null) + min = child.getSize(); + int minX = b.x + b.width; + int minY = b.y + b.height; + int maxX = b.x + b.width; + int maxY = b.y + b.height; + if (ld instanceof AnchorConstraint) { + AnchorConstraint ac = (AnchorConstraint) ld; + int acl = ac.left; + int acr = ac.right; + int aclt = ac.leftType; + int acrt = ac.rightType; + + if (aclt == AnchorConstraint.ANCHOR_REL) + acl = acl * pb.width / 1000; + if (acrt == AnchorConstraint.ANCHOR_REL) + acr = pb.width - acr * pb.width / 1000; + + if (aclt != AnchorConstraint.ANCHOR_NONE + && acrt != AnchorConstraint.ANCHOR_NONE) + maxX = acl + pref.width + acr; + if (aclt == AnchorConstraint.ANCHOR_NONE) + acl = 0; + if (acrt == AnchorConstraint.ANCHOR_NONE) + acr = 0; + minX = acl + min.width + acr; + + int act = ac.top; + int acb = ac.bottom; + int actt = ac.topType; + int acbt = ac.bottomType; + if (actt == AnchorConstraint.ANCHOR_REL) + act = act * pb.height / 1000; + if (acbt == AnchorConstraint.ANCHOR_REL) + acb = pb.height - acb * pb.height / 1000; + + if (actt != AnchorConstraint.ANCHOR_NONE + && acbt != AnchorConstraint.ANCHOR_NONE) + maxY = act + pref.height + acb; + if (actt == AnchorConstraint.ANCHOR_NONE) + act = 0; + if (acbt == AnchorConstraint.ANCHOR_NONE) + acb = 0; + minY = act + min.height + acb; + } + if (minX > minWidth) + minWidth = minX; + if (maxX > minWidth) + preferredWidth = maxX; + if (minY > minHeight) + minHeight = minY; + if (maxY > preferredHeight) + preferredHeight = maxY; + } + } + + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean) + */ + public void layoutContainer(Container container) { + this.container = container; + Component children[] = container.getComponents(); + Rectangle rect = container.getBounds(); + int width = rect.width; + int height = rect.height; + for (int i = 0; i < children.length; i++) { + Component child = children[i]; + if (child != null) { + Object ld = constraintMap.get(child); + Rectangle b = child.getBounds(); + Dimension pref = child.getPreferredSize(); + if (pref == null) + pref = child.getSize(); + if (ld instanceof AnchorConstraint) { + AnchorConstraint ac = (AnchorConstraint) ld; + int acl = ac.left; + int acr = ac.right; + int aclt = ac.leftType; + int acrt = ac.rightType; + if (aclt == AnchorConstraint.ANCHOR_REL) + acl = acl * width / 1000; + if (acrt == AnchorConstraint.ANCHOR_REL) + acr = width - acr * width / 1000; + + if (aclt != AnchorConstraint.ANCHOR_NONE) { + if (acrt != AnchorConstraint.ANCHOR_NONE) { + b.width = width - acr - acl; + b.x = acl; + } else { + b.width = pref.width; + if (b.width + acl > width) + b.width = width - acl; + b.x = acl; + } + } else { + if (acrt != AnchorConstraint.ANCHOR_NONE) { + b.x = width - acr - pref.width; + } + b.width = pref.width; + if (b.width + b.x > width) + b.width = width - b.x; + } + + int act = ac.top; + int acb = ac.bottom; + int actt = ac.topType; + int acbt = ac.bottomType; + if (actt == AnchorConstraint.ANCHOR_REL) + act = act * height / 1000; + if (acbt == AnchorConstraint.ANCHOR_REL) + acb = height - acb * height / 1000; + + if (actt != AnchorConstraint.ANCHOR_NONE) { + if (acbt != AnchorConstraint.ANCHOR_NONE) { + b.height = height - acb - act; + b.y = act; + } else { + b.height = pref.height; + if (b.height + act > height) + b.height = height - act; + b.y = act; + } + } else { + if (acbt != AnchorConstraint.ANCHOR_NONE) { + b.y = height - acb - pref.height; + } + b.height = pref.height; + if (b.height + b.y > height) + b.height = height - b.y; + } + child.setBounds(b); + } + } + } + } + + /* (non-Javadoc) + * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component) + */ + public void addLayoutComponent(String name, Component comp) {} + + /* (non-Javadoc) + * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component) + */ + public void removeLayoutComponent(Component comp) { + constraintMap.remove(comp); + } + + /* (non-Javadoc) + * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container) + */ + public Dimension preferredLayoutSize(Container parent) { + initialize(parent); + return new Dimension(preferredWidth, preferredHeight); + } + + /* (non-Javadoc) + * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container) + */ + public Dimension minimumLayoutSize(Container parent) { + initialize(parent); + return new Dimension(minWidth, minHeight); + } + + /* (non-Javadoc) + * @see java.awt.LayoutManager2#addLayoutComponent(java.awt.Component, java.lang.Object) + */ + public void addLayoutComponent(Component comp, Object constraints) { + constraintMap.put(comp, constraints); + } + + /* (non-Javadoc) + * @see java.awt.LayoutManager2#maximumLayoutSize(java.awt.Container) + */ + public Dimension maximumLayoutSize(Container target) { + return preferredLayoutSize(target); + } + + /* (non-Javadoc) + * @see java.awt.LayoutManager2#getLayoutAlignmentX(java.awt.Container) + */ + public float getLayoutAlignmentX(Container target) { + return 0; + } + + /* (non-Javadoc) + * @see java.awt.LayoutManager2#getLayoutAlignmentY(java.awt.Container) + */ + public float getLayoutAlignmentY(Container target) { + return 0; + } + + /* (non-Javadoc) + * @see java.awt.LayoutManager2#invalidateLayout(java.awt.Container) + */ + public void invalidateLayout(Container target) { + sizesCalculated = false; + } + +} Added: software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ATTConfig.java =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ATTConfig.java (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ATTConfig.java 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,96 @@ +package com.tuxisalive.attitunes; + +/** + * + * @author R Jocaille + * + */ +public interface ATTConfig +{ + public static int TLV_LEFT = 100; + public static int TLV_TOP = 45; + public static int TLV_BOTTOM_BORDER = 60; + public static int TLV_RIGHT_BORDER = 30; + + public static double INDICES_PER_PIXEL = 0.0159; + public static double ZOOM_DEPTH_COEFF = 1.666666; + + public static float[] SB_BACKGROUND_FILL_COLOR = {0.7f, 0.7f, 0.7f, 0.5f}; + public static float[] SB_BACKGROUND_LINE_COLOR = {1.0f, 1.0f, 1.0f, 1.0f}; + public static float[] SB_FRONT_LINE_COLOR = {0.0f, 0.0f, 0.0f, 1.0f}; + public static float[][] SB_FRONT_FILL_COLORS = { + {0.82f, 0.89f, 0.92f, 1.0f}, + {0.75f, 0.82f, 0.789f, 1.0f}, + {0.7f, 0.77f, 0.84f, 1.0f}, + }; + + public static int SB_HEIGHT = 17; + public static int SB_TOP_BORDER = 5; + + public static float[] BLOCK_VIEWER_FILL_COLOR = {0.7f, 0.7f, 0.7f, 0.9f}; + public static float[] PARTS_VIEWER_FILL_COLOR = {0.93f, 0.93f, 0.93f, 1.f}; + + public static float[] CURRENT_POS_BAR_COLOR = {1.0f, 0.0f, 0.0f, 0.6f}; + + public static int BLOCK_TYPE_LEDS = 0; + public static int BLOCK_TYPE_EYESMOUTH = 1; + public static int BLOCK_TYPE_WINGS = 2; + public static int BLOCK_TYPE_SPIN = 3; + public static int BLOCK_TYPE_WAV = 4; + public static int BLOCK_TYPE_TTS = 5; + public static int BLOCK_COUNT_TYPE = 6; + + public static float BLOCK_ALPHA_COLOR_VALUE = 0.8f; + + public static float[][] BLOCK_BLUE_COLORS = { + {0.32f, 0.6f, 0.83f, BLOCK_ALPHA_COLOR_VALUE}, + {0.28f, 0.53f, 0.79f, BLOCK_ALPHA_COLOR_VALUE}, + {0.20f, 0.40f, 0.68f, BLOCK_ALPHA_COLOR_VALUE}, + }; + public static float[][] BLOCK_ORANGE_COLORS = { + {0.92f, 0.71f, 0.20f, BLOCK_ALPHA_COLOR_VALUE}, + {0.88f, 0.66f, 0.216f, BLOCK_ALPHA_COLOR_VALUE}, + {0.75f, 0.49f, 0.0f, BLOCK_ALPHA_COLOR_VALUE}, + }; + public static float[][] BLOCK_RED_COLORS = { + {0.83f, 0.22f, 0.22f, 0.65f}, + {0.79f, 0.18f, 0.18f, 0.65f}, + {0.68f, 0.10f, 0.10f, 0.65f}, + }; + public static float[][] BLOCK_GREY_COLORS = { + {0.70f, 0.70f, 0.70f, BLOCK_ALPHA_COLOR_VALUE}, + {0.65f, 0.65f, 0.65f, BLOCK_ALPHA_COLOR_VALUE}, + {0.50f, 0.50f, 0.50f, BLOCK_ALPHA_COLOR_VALUE}, + }; + public static float[][] BLOCK_LIGHT_BLUE_COLORS = { + {0.82f, 0.89f, 0.92f, BLOCK_ALPHA_COLOR_VALUE}, + {0.75f, 0.82f, 0.789f, BLOCK_ALPHA_COLOR_VALUE}, + {0.7f, 0.77f, 0.84f, BLOCK_ALPHA_COLOR_VALUE}, + }; + + public static String EVENT_POSITION_CHANGED = "position_changed"; + public static String EVENT_LENGTH_CHANGED = "length_changed"; + public static String EVENT_ZOOM_CHANGED = "zoom_changed"; + public static String EVENT_ROW_SELECTED = "row_selected"; + public static String EVENT_BLOCK_SELECTED = "block_selected"; + public static String EVENT_BLOCK_DRAG_STARTED = "block_drag_started"; + public static String EVENT_BLOCK_DRAG_STOPPED = "block_drag_stopped"; + public static String EVENT_BLOCK_DRAGGING = "block_dragging"; + public static String EVENT_SCROLLBAR_DRAG_STARTED = "scrollbar_drag_started"; + public static String EVENT_SCROLLBAR_DRAG_STOPPED = "scrollbar_drag_stopped"; + public static String EVENT_SCROLLBAR_DRAGGING = "scrollbar_dragging"; + + public static String[] EVENT_LIST = { + EVENT_POSITION_CHANGED, + EVENT_LENGTH_CHANGED, + EVENT_ZOOM_CHANGED, + EVENT_ROW_SELECTED, + EVENT_BLOCK_SELECTED, + EVENT_BLOCK_DRAG_STARTED, + EVENT_BLOCK_DRAG_STOPPED, + EVENT_BLOCK_DRAGGING, + EVENT_SCROLLBAR_DRAG_STARTED, + EVENT_SCROLLBAR_DRAG_STOPPED, + EVENT_SCROLLBAR_DRAGGING, + }; +} \ No newline at end of file Added: software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ATTMisc.java =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ATTMisc.java (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/ATTMisc.java 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,44 @@ +package com.tuxisalive.attitunes; + +/** + * + * @author R Jocaille + * + */ +public class ATTMisc +{ + + /** + * + * @param time + * @return + */ + public static String timeToString(double time) + { + int dMSec = (int)(time * 1000); + int minutes = dMSec / 60000; + int reste = dMSec % 60000; + int seconds = reste / 1000; + reste %= 1000; + int mSeconds = reste / 10; + return String.format("%02d:%02d:%02d", minutes, seconds, mSeconds); + } + + /** + * + * @param sec + */ + public static void sleep(Double sec) + { + int delay; + + try + { + sec = sec * 1000; + delay = sec.intValue(); + Thread.sleep(delay); + } + catch(Exception e) {} + } + +} Added: software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlock.java =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlock.java (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlock.java 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,605 @@ +package com.tuxisalive.attitunes.block; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Polygon; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; + +//import others.ReadFileIntoByteArray; + +import com.tuxisalive.attitunes.ATTConfig; +import com.tuxisalive.attitunes.vector.ATTAreaVector; +import com.tuxisalive.attitunes.vector.ATTPointVector; + + +/** + * + * @author R Jocaille + * + */ +public class ATTBlock +{ + private boolean visible; + public ATTPointVector lastClickedPoint; + private boolean focused; + private int blockType; + private double timeBegin; + private double length; + public boolean aLive; + private ATTAreaVector area; + private double viewWidthCoeff; + private double rowViewPosition; + private List<Integer> wavEnergyTable; + private String waveFile; + private Hashtable<String,Object> function; + + static private Color blockBlueColor0; + static private Color blockBlueColor1; + static private Color blockBlueColor2; + static private Color blockOrangeColor0; + static private Color blockOrangeColor1; + static private Color blockOrangeColor2; + static private Color blockRedColor0; + static private Color blockRedColor1; + static private Color blockRedColor2; + static private Color blockLightBlueColor0; + static private Color blockLightBlueColor1; + static private Color blockLightBlueColor2; + static private Color blockWaveformColor; + + static { + blockBlueColor0 = new Color(ATTConfig.BLOCK_BLUE_COLORS[0][0], + ATTConfig.BLOCK_BLUE_COLORS[0][1], + ATTConfig.BLOCK_BLUE_COLORS[0][2], + ATTConfig.BLOCK_BLUE_COLORS[0][3]); + blockBlueColor1 = new Color(ATTConfig.BLOCK_BLUE_COLORS[1][0], + ATTConfig.BLOCK_BLUE_COLORS[1][1], + ATTConfig.BLOCK_BLUE_COLORS[1][2], + ATTConfig.BLOCK_BLUE_COLORS[1][3]); + blockBlueColor2 = new Color(ATTConfig.BLOCK_BLUE_COLORS[2][0], + ATTConfig.BLOCK_BLUE_COLORS[2][1], + ATTConfig.BLOCK_BLUE_COLORS[2][2], + ATTConfig.BLOCK_BLUE_COLORS[2][3]); + blockOrangeColor0 = new Color(ATTConfig.BLOCK_ORANGE_COLORS[0][0], + ATTConfig.BLOCK_ORANGE_COLORS[0][1], + ATTConfig.BLOCK_ORANGE_COLORS[0][2], + ATTConfig.BLOCK_ORANGE_COLORS[0][3]); + blockOrangeColor1 = new Color(ATTConfig.BLOCK_ORANGE_COLORS[1][0], + ATTConfig.BLOCK_ORANGE_COLORS[1][1], + ATTConfig.BLOCK_ORANGE_COLORS[1][2], + ATTConfig.BLOCK_ORANGE_COLORS[1][3]); + blockOrangeColor2 = new Color(ATTConfig.BLOCK_ORANGE_COLORS[2][0], + ATTConfig.BLOCK_ORANGE_COLORS[2][1], + ATTConfig.BLOCK_ORANGE_COLORS[2][2], + ATTConfig.BLOCK_ORANGE_COLORS[2][3]); + blockRedColor0 = new Color(ATTConfig.BLOCK_RED_COLORS[0][0], + ATTConfig.BLOCK_RED_COLORS[0][1], + ATTConfig.BLOCK_RED_COLORS[0][2], + ATTConfig.BLOCK_RED_COLORS[0][3]); + blockRedColor1 = new Color(ATTConfig.BLOCK_RED_COLORS[1][0], + ATTConfig.BLOCK_RED_COLORS[1][1], + ATTConfig.BLOCK_RED_COLORS[1][2], + ATTConfig.BLOCK_RED_COLORS[1][3]); + blockRedColor2 = new Color(ATTConfig.BLOCK_RED_COLORS[2][0], + ATTConfig.BLOCK_RED_COLORS[2][1], + ATTConfig.BLOCK_RED_COLORS[2][2], + ATTConfig.BLOCK_RED_COLORS[2][3]); + blockLightBlueColor0 = new Color(ATTConfig.BLOCK_LIGHT_BLUE_COLORS[0][0], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[0][1], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[0][2], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[0][3]); + blockLightBlueColor1 = new Color(ATTConfig.BLOCK_LIGHT_BLUE_COLORS[1][0], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[1][1], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[1][2], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[1][3]); + blockLightBlueColor2 = new Color(ATTConfig.BLOCK_LIGHT_BLUE_COLORS[2][0], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[2][1], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[2][2], + ATTConfig.BLOCK_LIGHT_BLUE_COLORS[2][3]); + blockWaveformColor = new Color(0.f, 0.f, 0.f, 0.5f); + } + + /** + * + * @param blockType + */ + public ATTBlock(int blockType) + { + visible = true; + lastClickedPoint = new ATTPointVector(); + lastClickedPoint.x = 0; + lastClickedPoint.y = 0; + focused = false; + this.blockType = blockType; + timeBegin = 0.; + length = 1.0; + aLive = true; + area = new ATTAreaVector(); + area.top = 0; + area.left = 0; + area.width = 0; + area.height = 0; + viewWidthCoeff = 0.; + rowViewPosition = 0.0; + wavEnergyTable = new ArrayList<Integer>(); + waveFile = ""; + function = new Hashtable<String,Object>(); + } + + /** + * + * @param value + */ + public void setPosition(double value) + { + if ((value >= 0.0) && (value <= 600. - length)) + { + timeBegin = value; + } + } + + /** + * + * @return + */ + public double getPosition() + { + return timeBegin; + } + + /** + * + * @param value + */ + public void setLength(double value) + { + if (value < 0.3) + { + value = 0.3; + } + length = value; + function.put("duration", (Double)value); + } + + /** + * + * @return + */ + public double getLength() + { + return length; + } + + /** + * + * @param fp + */ + public void setFunctionParams(Hashtable<String,Object> fp) + { + function.clear(); + + Iterator<String> it = fp.keySet().iterator(); + while (it.hasNext()) + { + String key = it.next(); + function.put(key, fp.get(key)); + } + + if (function.containsKey("duration")) + { + setLength((Double)function.get("duration")); + } + else + { + setLength(0.); + } + } + + /** + * + * @return + */ + public Hashtable<String,Object> getFunctionParams() + { + return function; + } + + /** + * + * @return + */ + public boolean isAssigned() + { + if (function.size() > 0) + { + return true; + } + else + { + return false; + } + } + + /** + * + * @return + */ + public boolean haveDuration() + { + if (function.containsKey("duration")) + { + if ((Double)function.get("duration") > 0.) + { + return true; + } + } + return false; + } + + /** + * + * @return + */ + public String getWavPath() + { + return waveFile; + } + + /** + * + */ + public void closeWaveFile() + { + wavEnergyTable.clear(); + setLength(0.); + } + + /* + * + */ + private int logVal(double val) + { + if (val < 0) + { + val = Math.abs(val); + } + + if (val < 1.) + { + val = 1.; + } + + return -(int)(((double)(Math.log(val) / Math.log(127.))) * 127.); + } + + /* + * + */ + private static byte[] byteArrayFromWaveFile(String path) throws IOException + { + byte[] result; + File f = new File(path); + int waveLength = (int)f.length(); + int bIdx = 0; + int bRead = 1; + InputStream waveIS = new FileInputStream(f); + + result = new byte[waveLength]; + + while (bRead != 0) + { + bRead = waveIS.read(result, bIdx, result.length - bIdx); + + if (bRead != 0) + { + bIdx += bRead; + } + + if (bIdx >= waveLength) + { + break; + } + } + + waveIS.close(); + return result; + } + + /** + * + * @param path + * @return + */ + public boolean loadWaveFile(String path) + { + byte[] waveFormByteArray = null; + int[] waveFormIntArray = null; + int i, j; + double accu; + + try + { + waveFormByteArray = byteArrayFromWaveFile(path); + } + catch (IOException e) + { + return false; + } + + waveFormIntArray = new int[waveFormByteArray.length - 44]; + j = 0; + + for (i = 44; i < waveFormByteArray.length; i++) + { + waveFormIntArray[j] = 128 - Math.abs(waveFormByteArray[i]); + j++; + } + + wavEnergyTable.clear(); + + for (i = 0; i < (waveFormIntArray.length / 10); i++) + { + accu = 0.; + for (j = 0; j < 10; j++) + { + accu += waveFormIntArray[i * 10 + j]; + } + accu /= 10.; + wavEnergyTable.add(logVal(accu)); + } + + setLength((double)(wavEnergyTable.size() / 800.)); + + return true; + } + + /** + * + * @param value + */ + public void setFocused(boolean value) + { + focused = value; + } + + /** + * + * @return + */ + public boolean getFocused() + { + return focused; + } + + /** + * + * @param g + */ + public void draw(Graphics g) + { + Color color0 = blockBlueColor0; + Color color1 = blockBlueColor1; + Color color2 = blockBlueColor2; + + if (!aLive) + { + return; + } + if (!visible) + { + return; + } + + if (area.width == 0) + { + return; + } + else if (focused) + { + color0 = blockRedColor0; + color1 = blockRedColor1; + color2 = blockRedColor2; + } + else + { + if (blockType == ATTConfig.BLOCK_TYPE_WAV) + { + color0 = blockLightBlueColor0; + color1 = blockLightBlueColor1; + color2 = blockLightBlueColor2; + } + else if (blockType == ATTConfig.BLOCK_TYPE_TTS) + { + color0 = blockLightBlueColor0; + color1 = blockLightBlueColor1; + color2 = blockLightBlueColor2; + } + else if (blockType == ATTConfig.BLOCK_TYPE_EYESMOUTH) + { + if (function.containsKey("cmd")) + { + String cmd = (String)function.get("cmd"); + + if (cmd.contains("mouth")) + { + color0 = blockOrangeColor0; + color1 = blockOrangeColor1; + color2 = blockOrangeColor2; + } + } + } + } + + g.setColor(color0); + g.fillRect(area.left + 1, + area.top + 1, + area.width - 1, + 6); + g.setColor(color1); + g.fillRect(area.left + 1, + area.top + 7, + area.width - 1, + 2); + g.setColor(color2); + g.fillRect(area.left + 1, + area.top + 9, + area.width - 1, + 18); + g.setColor(Color.BLACK); + g.drawRect(area.left, + area.top, + area.width, + area.height); + + /* Draw waveform if exists */ + if (wavEnergyTable.size() == 0) + { + return; + } + + double pixWavValCoeff = (double)(area.height - 2) / 256.; + double relBlockBeginPos = rowViewPosition - getPosition(); + + if (relBlockBeginPos < 0.) + { + relBlockBeginPos = 0.; + } + + Polygon p = new Polygon(); + + int yRel = area.top + (area.height / 2); + int xRel = area.left + 1; + double idxTime; + int eIdx; + int val; + int x, y; + int idx; + + p.addPoint(xRel, yRel); + + for (int i = 0; i < area.width; i++) + { + idxTime = relBlockBeginPos + (i * viewWidthCoeff); + eIdx = (int)(idxTime * 800); + if (eIdx < wavEnergyTable.size()) + { + val = (int)(Math.abs(wavEnergyTable.get(eIdx)) * pixWavValCoeff); + x = i + xRel; + y = yRel - val; + p.addPoint(x, y); + } + } + + for (int i = 0; i < area.width; i++) + { + idx = area.width - 1 - i; + idxTime = relBlockBeginPos + (idx * viewWidthCoeff); + eIdx = (int)(idxTime * 800); + if (eIdx < wavEnergyTable.size()) + { + val = (int)(-Math.abs(wavEnergyTable.get(eIdx)) * pixWavValCoeff); + x = idx + xRel; + y = yRel - val; + p.addPoint(x, y); + } + } + + g.setColor(blockWaveformColor); + g.fillPolygon(p); + g.setColor(Color.BLACK); + g.drawPolygon(p); + } + + /** + * + * @param rowViewCell + * @param viewTimePosition + * @param viewTimeLength + * @param cursorPosition + */ + public void updateCoord(ATTAreaVector rowViewCell, double viewTimePosition, + double viewTimeLength, double cursorPosition) + { + int border = rowViewCell.height / 8; + area.top = rowViewCell.top + border - 1; + area.height = rowViewCell.height - (border * 2) + 2; + viewWidthCoeff = viewTimeLength / (double)rowViewCell.width; + rowViewPosition = viewTimePosition; + double tB = viewTimePosition; + double tE = viewTimePosition + viewTimeLength; + + if (timeBegin > tE) + { + visible = false; + area.width = 0; + return; + } + + if ((timeBegin + length) < tB) + { + visible = false; + area.width = 0; + return; + } + + double mtB; + double mtE; + + if (timeBegin < tB) + { + mtB = tB; + } + else + { + mtB = timeBegin; + } + + if ((timeBegin + length) > tE) + { + mtE = tE; + } + else + { + mtE = timeBegin + length; + } + + area.left = (int)((mtB / viewWidthCoeff) - (viewTimePosition / viewWidthCoeff) + rowViewCell.left); + area.width = (int)Math.floor((mtE - mtB) / viewWidthCoeff); + visible = true; + } + + /** + * + * @param x + * @param y + * @param cursorPosition + * @return + */ + public boolean pointInBlock(int x, int y, double cursorPosition) + { + int xb; + int mx; + boolean ret = false; + + if ((x > area.left) && (x < (area.left + area.width))) + { + if ((y > area.top) && (y < (area.top + area.height))) + { + ret = true; + xb = (int)(timeBegin / viewWidthCoeff); + mx = (int)(cursorPosition / viewWidthCoeff); + lastClickedPoint.x = mx - xb; + lastClickedPoint.y = y - area.top; + } + } + + return ret; + } +} Added: software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlockContainer.java =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlockContainer.java (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlockContainer.java 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,267 @@ +package com.tuxisalive.attitunes.block; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.ArrayList; +import java.util.List; + +import com.tuxisalive.attitunes.ATTConfig; +import com.tuxisalive.attitunes.vector.ATTAreaVector; +import com.tuxisalive.attitunes.vector.ATTTlvVector; + +/** + * + * @author R Jocaille + * + */ +public class ATTBlockContainer +{ + public List<ATTBlock> blocks; + public int blockType; + private ATTAreaVector area; + static private Color focusColor; + private boolean focused; + private String label; + private Image icon; + static private Font labelFont; + + static { + focusColor = new Color(1.f, 0.f, 0.f, 0.13f); + labelFont = new Font("SansSerif", Font.PLAIN, 10); + } + + /** + * + * @param blockType + * @param minEcart + * @param backgroundColor + */ + public ATTBlockContainer(int blockType) + { + blocks = new ArrayList<ATTBlock>(); + area = new ATTAreaVector(); + area.top = 0; + area.left = 0; + area.width = 0; + area.height = 0; + focused = false; + label = "Undefined"; + this.blockType = blockType; + icon = null; + } + + /** + * + * @return + */ + public List<List<Object>> getBlockList() + { + List<List<Object>> result = new ArrayList<List<Object>>(); + ATTBlock block; + + for (int i = 0; i < blocks.size(); i++) + { + block = blocks.get(i); + if (block.aLive) + { + List<Object> blockInfo = new ArrayList<Object>(); + blockInfo.add(block.getPosition()); + blockInfo.add(block.getFunctionParams()); + blockInfo.add(block); + result.add(blockInfo); + } + } + + return result; + } + + /** + * + * @param text + * @param iconPath + */ + public void setLabel(String text, String iconPath) + { + label = text; + icon = Toolkit.getDefaultToolkit().getImage(getClass().getResource(iconPath)); + } + + /** + * + * @param value + */ + public void setFocused(boolean value) + { + focused = value; + } + + /** + * + * @return + */ + public boolean getFocused() + { + return focused; + } + + /** + * + * @param g + */ + public void draw(Graphics g) + { + int x = area.left - 97; + int y = area.top; + int w, h; + + /* Draw lines */ + g.setColor(Color.BLACK); + g.drawLine(x, y, area.width + 99, y); + y += area.height; + g.drawLine(x, y, area.width + 99, y); + + /* Draw Label */ + x = area.left - 90; + y = area.top + 15; + g.setColor(Color.BLACK); + g.setFont(labelFont); + String[] labelS = label.split("\n"); + g.drawString(labelS[0], x, y); + + if (labelS.length > 1) + { + y = area.top + 25; + g.drawString(labelS[1], x, y); + } + + /* Draw focus */ + if (focused) + { + x = area.left - 97; + w = area.width + 98; + y = area.top + 1; + h = area.height - 1; + + g.setColor(focusColor); + g.fillRect(x, y, w, h); + } + + /* Draw icon */ + if(icon != null) + { + g.drawImage(icon, area.left - 34, area.top + 1, null); + } + } + + /** + * + * @param g + */ + public void drawAll(Graphics g) + { + ATTBlock block; + + this.draw(g); + + for (int i = 0; i < blocks.size(); i++) + { + block = blocks.get(i); + if (block.aLive) + { + block.draw(g); + } + } + } + + /** + * + * @param mainView + * @param cursorPosition + */ + public void updateCoord(ATTTlvVector mainView, double cursorPosition) + { + ATTBlock block; + double flAreaHeight; + int tmpVal; + + flAreaHeight = (double)mainView.height / ATTConfig.BLOCK_COUNT_TYPE; + area.top = (int)(flAreaHeight * blockType) + mainView.top; + tmpVal = (int)(flAreaHeight * (blockType + 1)) + mainView.top; + area.height = tmpVal - area.top; + area.width = mainView.width; + area.left = mainView.left; + + for (int i = 0; i < blocks.size(); i++) + { + block = blocks.get(i); + if (block.aLive) + { + block.updateCoord(area, mainView.timePosition, mainView.timeLength, cursorPosition); + } + } + } + + /** + * + * @return + */ + public ATTBlock newBlock() + { + ATTBlock result = new ATTBlock(blockType); + blocks.add(result); + + return result; + } + + /** + * + * @param blockId + * @return + */ + public boolean deleteBlock(int blockId) + { + if (blockId < blocks.size()) + { + blocks.get(blockId).aLive = false; + return true; + } + return false; + } + + /** + * + */ + public void clearBlocks() + { + blocks.clear(); + } + + /** + * + * @param x + * @param y + * @return + */ + public boolean pointInRow(int x, int y) + { + boolean ret = false; + int xb; + int xe; + + xb = area.left - 100; + xe = xb + area.width + 100; + + if ((x >= xb) && (x <= xe)) + { + if ((y >= area.top) && (y <= (area.top + area.height))) + { + ret = true; + } + } + + return ret; + } +} Added: software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java =================================================================== --- software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java (rev 0) +++ software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java 2008-07-29 08:07:47 UTC (rev 1411) @@ -0,0 +1,176 @@ +package com.tuxisalive.attitunes.format; + +import java.util.Hashtable; + +public class ATTBlockParams +{ + /* + * Led commands + */ + public static Hashtable<String,Object> LEDS_BLINK_CANVAS = new Hashtable<String,Object>(); + static { + LEDS_BLINK_CANVAS.put("cmd", "leds_blink"); + LEDS_BLINK_CANVAS.put("count", 1.0); + LEDS_BLINK_CANVAS.put("speed", 1); + } + public static Hashtable<String,Object> LEDS_ON_CANVAS = new Hashtable<String,Object>(); + static { + LEDS_ON_CANVAS.put("cmd", "leds_on"); + LEDS_ON_CANVAS.put("duration", 0.0); + } + public static Hashtable<String,Object> LEDL_ON_CANVAS = new Hashtable<String,Object>(); + static { + LEDL_ON_CANVAS.put("cmd", "ledl_on"); + LEDL_ON_CANVAS.put("duration", 0.0); + } + public static Hashtable<String,Object> LEDR_ON_CANVAS = new Hashtable<String,Object>(); + static { + LEDR_ON_CANVAS.put("cmd", "ledr_on"); + LEDR_ON_CANVAS.put("duration", 0.0); + } + public static Hashtable<String,Object> LEDS_OFF_CANVAS = new Hashtable<String,Object>(); + static { + LEDS_OFF_CANVAS.put("cmd", "leds_off"); + LEDS_OFF_CANVAS.put("duration", 0.0); + } + public static Hashtable<String,Object> LEDL_OFF_CANVAS = new Hashtable<String,Object>(); + static { + LEDL_OFF_CANVAS.put("cmd", "ledl_off"); + LEDL_OFF_CANVAS.put("duration", 0.0); + } + public static Hashtable<String,Object> LEDR_OFF_CANVAS = new Hashtable<String,Object>(); + static { + LEDR_OFF_CANVAS.put("cmd", "ledr_off"); + LEDR_OFF_CANVAS.put("duration", 0.0); + } + public static String[] LEDS_CMD_TYPES = { + "leds_blink", + "leds_on", + "ledl_on", + "ledr_on", + "leds_off", + "ledl_off", + "ledr_off" + }; + /* + * Mouth and eyes commands + */ + public static Hashtable<String,Object> MOUTH_ON_CANVAS = new Hashtable<String,Object>(); + static { + MOUTH_ON_CANVAS.put("cmd", "mouth_on"); + MOUTH_ON_CANVAS.put("duration", 0.0); + MOUTH_ON_CANVAS.put("count", 2); + } + public static Hashtable<String,Object> MOUTH_OPEN_CANVAS = new Hashtable<String,Object>(); + static { + MOUTH_OPEN_CANVAS.put("cmd", "mouth_open"); + MOUTH_OPEN_CANVAS.put("duration", 0.0); + } + public static Hashtable<String,Object> MOUTH_CLOSE_CANVAS = new Hashtable<String,Object>(); + static { + MOUTH_CLOSE_CANVAS.put("cmd", "mouth_close"); + MOUTH_CLOSE_CANVAS.put("duration", 0.0); + } + public static Hashtable<String,Object> EYES_ON_CANVAS = new Hashtable<String,Object>(); + static { + EYES_ON_CANVAS.put("cmd", "eyes_on"); + EYES_ON_CANVAS.put("duration", 0.0); + EYES_ON_CANVAS.put("count", 2); + } + public static Hashtable<String,Object> EYES_OPEN_CAN... [truncated message content] |