package scala2d
The scala2d
package contains classes, traits and objects for
simple 2D graphics in Scala, based upon java.swing
, java.awt
and
It makes java.awt
and javax.swing
GUI classes available
and insulates the rest of ScalaTion from changes to GUI libraries.
Only scalation.scala2d
should import from java.awt or
javax.swing.
- See also
Shapes.scala
for providing classes injava.awt.geom
.
- Alphabetic
- By Inheritance
- scala2d
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
case class
Arc() extends Double with Product with Serializable
Arc
is a convenience case class forArc2D
(a subclass ofRectangularShape
). -
case class
Arrow(p1: R2 = R2 (0.0, 0.0), p2: R2 = R2 (0.0, 0.0), len: Int = 10) extends Double with Product with Serializable
The
Arrow
class uses Java's Path2D class to create a line with an arrowhead on the far end.The
Arrow
class uses Java's Path2D class to create a line with an arrowhead on the far end. The main line is defined by points 'p1' and 'p2'. Points 'p3' and 'p4' are the corners of the triangular arrowhead.- p1
the starting point for the line/arrow
- p2
the ending point for the line/arrow
- len
the length of the arrowhead on the line/arrow
-
trait
CurvilinearShape extends Shape with Error
The
CurvilinearShape
trait provides a general type for line and curves.The
CurvilinearShape
trait provides a general type for line and curves. It is analogous toRectangularShape
. -
case class
Ellipse() extends Double with Product with Serializable
Ellipse
is a convenience case class for Ellipse2D (a subclass ofRectangularShape
). -
class
Frame extends JFrame
The
Frame
class is a convenience class forJFrame
. -
case class
Hexagon(vertex: Array[R2]) extends Double with Product with Serializable
The
Hexagon
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building a hexagon given its vertices.The
Hexagon
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building a hexagon given its vertices.- vertex
the six corner points of the hexagon
- type Label = JLabel
-
case class
Line(p1: R2 = R2 (0.0, 0.0), p2: R2 = R2 (0.0, 0.0)) extends Double with Product with Serializable
Line
is a convenience case class forLine2D
(a subclass ofRectangularShape
). - type MouseAdapter = java.awt.event.MouseAdapter
- type MouseEvent = java.awt.event.MouseEvent
- type MouseListener = java.awt.event.MouseListener
-
case class
Octagon(vertex: Array[R2]) extends Double with Product with Serializable
The
Octagon
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building an octagon given its vertices.The
Octagon
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building an octagon given its vertices.- vertex
the eight corner points of the octagon
- type Panel = JPanel
-
case class
Path() extends Double with Product with Serializable
Path
is a convenience case class forPath2D.
Its subtypes (case classPolygon
, etc.) are defined in other files in thescala2d
package. -
case class
Pentagon(vertex: Array[R2]) extends Double with Product with Serializable
The
Pentagon
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building a pentagon given its vertices.The
Pentagon
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building a pentagon given its vertices.- vertex
the five corner points of the pentagon
-
case class
Polygon(vertex: Array[R2]) extends Double with Product with Serializable
The
Polygon
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building a polygon given its vertices.The
Polygon
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building a polygon given its vertices.- vertex
the n >= 3 corner points of the polygon
-
case class
QArrow(p1: R2 = R2 (0.0, 0.0), pc: R2 = R2 (0.0, 0.0), p2: R2 = R2 (0.0, 0.0), len: Int = 10) extends Double with CurvilinearShape with Product with Serializable
The
QArrow
class uses Java'sPath2D
class to create a quad curve with an arrowhead on the far end.The
QArrow
class uses Java'sPath2D
class to create a quad curve with an arrowhead on the far end. The main curve is defined by points 'p1' and 'p2' along with a control point 'pc'. Points 'p3' and 'p4' are the corners of the triangular arrowhead.- p1
the starting point for the curve/arc
- pc
the control point for the curve/arc
- p2
the ending point for the curve/arc
- len
the length of the arrowhead on the curve/arc
-
case class
QCurve(p1: R2 = R2 (0.0, 0.0), pc: R2 = R2 (0.0, 0.0), p2: R2 = R2 (0.0, 0.0), straight: Boolean = true) extends Double with CurvilinearShape with Product with Serializable
The
QCurve
class enhances theQuadCurve.Double
class (from thejava.awt.geom
package) by allowing entities to move along such quadratic curves as well as lines.The
QCurve
class enhances theQuadCurve.Double
class (from thejava.awt.geom
package) by allowing entities to move along such quadratic curves as well as lines. Although the curve could be developed as a quadratic function where 'y = ax2 + bx + c'. The following quadratic bezier formulation is used:
p(t) = (x(t), y(t)) = [(1-t)2 * p1] + [2 * (1-t) * t * pc] + [t^2 * p2].- p1
the starting point for the quad curve
- pc
the control point for the quad curve
- p2
the ending point for the quad curve
- straight
whether the quad curve is straight (i.e., a line)
-
case class
Quad(vertex: Array[R2]) extends Double with Product with Serializable
The
Quad
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building a quadrilateral given its vertices.The
Quad
class enhances thePath2D.Double
class (from thejava.awt.geom
package) by adding a constructor for building a quadrilateral given its vertices.- vertex
the four corner points of the quadrilateral
-
case class
R2(xx: Double, yy: Double) extends Double with Product with Serializable
R2
is a convenience case class forPoint2D
. -
case class
Rectangle() extends Double with Product with Serializable
Rectangle
is a convenience case class forRectangle2D
(a subclass ofRectangularShape
). -
case class
RoundRectangle() extends Double with Product with Serializable
RoundRectangle
is a convenience case class forRoundRectangle2D
(a subclass ofRectangularShape
). - type ScrollPane = JScrollPane
- type Table = JTable
-
trait
Transform extends AnyRef
The
Transform
trait provides a simple technique for transforming (translation, scaling and rotation) rectangular shapes. -
case class
Triangle(vertex: Array[R2]) extends Double with Product with Serializable
The Triangle class enhances the Path2D.Double class (from the
java.awt.geom
package) by adding a constructor for building a triangle given its vertices.The Triangle class enhances the Path2D.Double class (from the
java.awt.geom
package) by adding a constructor for building a triangle given its vertices.- vertex
the three corner points of the triangle
-
class
VizFrame extends Frame
The
VizFrame
class puts the canvas in the visualization/drawing frame.
Value Members
-
object
ArrowTest extends App
The
ArrowTest
object is used to test theArrow
class. -
object
BorderLayout extends BorderLayout
The
BorderLayout
object is a convenience object forjava.awt.BorderLayout
. -
object
Colors
The
Colors
convenience object defines numerous common colors.The
Colors
convenience object defines numerous common colors. Source of colors:- See also
www.webmoments.com/colorchart.htm
-
object
ColorsTest extends App
The
ColorsTest
object is used to test theColors
object. -
object
Constants
Useful constants.
-
object
PolygonTest extends App
The
PolygonTest
object tests thePolygon
,Triangle
,Quad
,Hexagon
and Octagon classes. -
object
QArrowTest extends App
The
QArrowTest
object is used to test theQArrow
class. -
object
QCurve extends Serializable
The
QCurve
companion object provides formulas used by theQCurve
class. -
object
QCurveTest extends App
The
QCurveTest
object tests theQCurve
classes' quad curves. -
object
QCurveTest2 extends App
The
QCurveTest2
object tests traversal ofQCurve
's (quad curves). -
object
Shapes
The
Shapes
object Scala provides type aliases for basic Java2D types.