Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

ch.laoe.ui
Class GEditableSegments  view GEditableSegments download GEditableSegments.java

java.lang.Object
  extended bych.laoe.ui.GEditableSegments

public class GEditableSegments
extends java.lang.Object

This file is part of LAoE. LAoE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. LAoE 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 General Public License for more details. You should have received a copy of the GNU General Public License along with LAoE; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Class: GEditableSegments Autor: olivier gäumann, neuchâtel (switzerland) JDK: 1.3 Desctription: reusable component to show, edit and apply segment-curves on channels. segments of 0th order, 1st order polynom and cubic spline interpolation. these curves can be made fully graphical, with the use of the mouse. once the curve edition terminated, the curve can be written to the actual channel. mouse action table of segment mode: --------------------------------------------------------- press-drag-release click --------------------------------------------------------- - move point add point shift - remove point ctrl move "locked" add point --------------------------------------------------------- History: Date: Description: Autor: 15.02.02 first draft, taken from FreeGenerator oli4


Nested Class Summary
private  class GEditableSegments.FPoint
           
 
Field Summary
private  int activePointIndex
           
private  ch.laoe.clip.AChannel actualChannel
           
private  ch.laoe.clip.AChannelPlotter actualChannelPlotter
           
private  java.awt.Rectangle actualChannelRect
           
private  java.awt.Cursor actualCursor
           
private  int actualOperation
           
private  java.awt.Color color
           
private static int DRAW
           
private  boolean editable
           
private  java.awt.Cursor eraseCursor
           
private  boolean highlightActivePoint
           
private static int IDLE
           
private  GEditableSegments.FPoint leftPoint
           
static int ORDER_0
           
static int ORDER_1
           
private  java.awt.Cursor penCursor
           
static int PERCENT_DOMAIN
           
private  boolean pointsVisible
           
private static int REMOVE
           
private  GEditableSegments.FPoint rightPoint
           
static int SAMPLE_DOMAIN
           
private  int segmentMode
           
private  java.util.ArrayList segmentPoints
           
private  java.awt.Stroke segmentSroke
          graphics
private  GEditableSegments.FPoint selectedPoint
           
static int SINGLE_POINTS
           
private  ch.laoe.operation.AOSpline spline
           
static int SPLINE
           
private  float[] x
           
private  float xMax
           
private  float xMin
           
private  float[] y
           
private  int yDomain
           
private  float yMax
           
private  float yMin
           
 
Constructor Summary
GEditableSegments()
           
GEditableSegments(GEditableSegments es)
          copy-constructor
 
Method Summary
 void addPoint(float x, float y)
          adds a point with the given coordinates in sample-domain
 void clear()
          reset segment points
 void clearXRange()
           
 void clearYRange()
           
 void convertToSamples(int operation)
          writes the samples in the channel
 void convertToSelectedSamples(int operation)
          writes the selected samples in the channel
 float getActivePointX()
           
 float getActivePointY()
           
 int getNumberOfPoints()
          returns the current number of points of the edited segment-line
 float getPointX(int index)
          get the x-coordinate of point at index index
 float getPointY(int index)
          get the y-coordinate of point at index index
 float getSample(int index)
          returns the sample
 int getSegmentMode()
           
 int getYDomain()
           
 boolean isEditable()
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          mouse events
 void paintOntoClip(java.awt.Graphics2D g2d, java.awt.Rectangle rect)
           
 void prepareResults()
          prepares the results, given through getSample() afterwards.
private  int searchInsertIndex(GEditableSegments.FPoint p)
          returns the index where the point p would be inserted
private  int searchNearest(GEditableSegments.FPoint p)
          returns nearest segment point index relative to p or -1 if not near enough
 void setChannel(ch.laoe.clip.AChannel ch)
          set the layer-model
 void setColor(java.awt.Color c)
           
 void setComplementary()
          transforms segment-points to complementary segment-points (1-x).
 void setEditable(boolean b)
           
 void setHighlightActivePointEnabled(boolean b)
           
 void setPointsVisible(boolean b)
           
 void setSegmentMode(int sm)
           
 void setXRange(float offset, float length)
           
 void setYDomain(int d)
           
 void setYRange(float offset, float length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

color

private java.awt.Color color

pointsVisible

private boolean pointsVisible

highlightActivePoint

private boolean highlightActivePoint

editable

private boolean editable

yDomain

private int yDomain

SAMPLE_DOMAIN

public static final int SAMPLE_DOMAIN
See Also:
Constant Field Values

PERCENT_DOMAIN

public static final int PERCENT_DOMAIN
See Also:
Constant Field Values

xMin

private float xMin

xMax

private float xMax

yMin

private float yMin

yMax

private float yMax

segmentPoints

private java.util.ArrayList segmentPoints

activePointIndex

private int activePointIndex

selectedPoint

private GEditableSegments.FPoint selectedPoint

leftPoint

private GEditableSegments.FPoint leftPoint

rightPoint

private GEditableSegments.FPoint rightPoint

spline

private ch.laoe.operation.AOSpline spline

actualOperation

private int actualOperation

IDLE

private static final int IDLE
See Also:
Constant Field Values

DRAW

private static final int DRAW
See Also:
Constant Field Values

REMOVE

private static final int REMOVE
See Also:
Constant Field Values

segmentMode

private int segmentMode

SINGLE_POINTS

public static final int SINGLE_POINTS
See Also:
Constant Field Values

ORDER_0

public static final int ORDER_0
See Also:
Constant Field Values

ORDER_1

public static final int ORDER_1
See Also:
Constant Field Values

SPLINE

public static final int SPLINE
See Also:
Constant Field Values

actualChannel

private ch.laoe.clip.AChannel actualChannel

actualChannelPlotter

private ch.laoe.clip.AChannelPlotter actualChannelPlotter

actualChannelRect

private java.awt.Rectangle actualChannelRect

penCursor

private java.awt.Cursor penCursor

eraseCursor

private java.awt.Cursor eraseCursor

actualCursor

private java.awt.Cursor actualCursor

x

private float[] x

y

private float[] y

segmentSroke

private java.awt.Stroke segmentSroke
graphics

Constructor Detail

GEditableSegments

public GEditableSegments()

GEditableSegments

public GEditableSegments(GEditableSegments es)
copy-constructor

Method Detail

setColor

public void setColor(java.awt.Color c)

setPointsVisible

public void setPointsVisible(boolean b)

setHighlightActivePointEnabled

public void setHighlightActivePointEnabled(boolean b)

setEditable

public void setEditable(boolean b)

isEditable

public boolean isEditable()

setYDomain

public void setYDomain(int d)

getYDomain

public int getYDomain()

setXRange

public void setXRange(float offset,
                      float length)

setYRange

public void setYRange(float offset,
                      float length)

clearXRange

public void clearXRange()

clearYRange

public void clearYRange()

setComplementary

public void setComplementary()
transforms segment-points to complementary segment-points (1-x). this is useful when using percent-y-domain.


getActivePointX

public float getActivePointX()

getActivePointY

public float getActivePointY()

setSegmentMode

public void setSegmentMode(int sm)

getSegmentMode

public int getSegmentMode()

setChannel

public void setChannel(ch.laoe.clip.AChannel ch)
set the layer-model


searchNearest

private int searchNearest(GEditableSegments.FPoint p)
returns nearest segment point index relative to p or -1 if not near enough


searchInsertIndex

private int searchInsertIndex(GEditableSegments.FPoint p)
returns the index where the point p would be inserted


clear

public void clear()
reset segment points


getNumberOfPoints

public int getNumberOfPoints()
returns the current number of points of the edited segment-line


addPoint

public void addPoint(float x,
                     float y)
adds a point with the given coordinates in sample-domain


getPointX

public float getPointX(int index)
get the x-coordinate of point at index index


getPointY

public float getPointY(int index)
get the y-coordinate of point at index index


convertToSamples

public void convertToSamples(int operation)
writes the samples in the channel


convertToSelectedSamples

public void convertToSelectedSamples(int operation)
writes the selected samples in the channel


prepareResults

public void prepareResults()
prepares the results, given through getSample() afterwards.


getSample

public float getSample(int index)
returns the sample


mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
mouse events


mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)

paintOntoClip

public void paintOntoClip(java.awt.Graphics2D g2d,
                          java.awt.Rectangle rect)