Package jltk.shape
Class Shape
- java.lang.Object
-
- jltk.Component
-
- jltk.shape.Shape
-
-
Field Summary
Fields Modifier and Type Field Description protected javafx.scene.paint.ColorfillColorjavafx.scene.shape.ShapefxShapeprotected javafx.scene.paint.ColorlineColorprotected javafx.scene.transform.Rotaterotateprotected javafx.scene.transform.Scalescaleprotected doubletransparancyprotected doublexprotected doublexOffsetprotected doubleyprotected doubleyOffset-
Fields inherited from class jltk.Component
fxNode, hasFocus, myWindow, onFocusGained, onFocusLost
-
-
Constructor Summary
Constructors Constructor Description Shape()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(double pX, double pY)Return true if the specified point is inside this shape.booleancontains(Shape pShape)Return true, if this shape fully includes the specified shape.static booleancontains(Shape pOuter, Shape pInner)Return true, if pOuter fully includes pInner.voiddelay(long pMilliseconds)Delay execution for this shape for the specfied number of millisecondsvoidflipHorizontal()voidflipVertical()doublegetHeight()Return the height of this shape.doublegetLineWidth()Return the current used linewidthdoublegetRotation()Return the current rotation of this shape.doublegetTransparancy()Return the transparancy of this shape. 0.0 means not transparent and 1.0 means full transparentdoublegetWidth()Return the width of this shape.doublegetX()Return the x coordinate of this shape.doublegetY()Return the y coordinate of upper left corner of the bounding box of this shapeprotected voidinit(double pX, double pY, Window pWindow, javafx.scene.shape.Shape pShape)Basic initialisation, like setting postion and size, add the Element to the window.booleanintersects(Shape pShape)Return true, if this shape intersects the specified shape.static booleanintersects(Shape pShape1, Shape pShape2)Return true, if the specified shapes intersectsvoidmove(double pDistance)Moves this shape by the specified distance into the current direction, seesetRotation(double).voidmove(double pX, double pY)Move this shape by the specified x- and y-sections.voidscale(double pScaleX, double pScaleY)Scale the shape with the specified factors.voidscaleTo(double pWidth, double pHeight)Scale the shape to the specified width and height.voidsetCenterPosition(double pX, double pY)Set the center of the shape to the specified position.voidsetFillColor(double pRed, double pGreen, double pBlue)The fillcolor of the shape will be changed to specified rgb-colorvoidsetFillColor(String pColor)The fill color of the shape will be changed to the specified color.voidsetFillColor(javafx.scene.paint.Color pColor)The fill color of the shape will be changed to the specified colorvoidsetLineColor(double pRed, double pGreen, double pBlue)The linecolor of the shape will be changed to specified rgb-colorvoidsetLineColor(String pColor)The line color of the shape will be changed to the specified color.voidsetLineColor(javafx.scene.paint.Color pColor)The line color of the shape will be changed to the specified colorvoidsetLineWidth(double pLineWidth)Set the width of the line/border to the specified value.voidsetPosition(double pX, double pY)Set the upper left corner of the shape to the specified position.voidsetRotation(double pAngle)Set the rotation of this shape to the specified angle.voidsetTransparancy(double pValue)Set the transparancy oh this shape to the specified value. pValue mus between 0.0 (not transparent) and 1.0 (transparent)voidturn(double pAngle)Turn this shape by the specified angle (in degrees).voidturn(double pX, double pY, double pAngle)Turn this schape by the specified angle (in degrees) arround the specified turning center Zero degrees is to the east (right-hand side of the window), and the angle increases clockwise.-
Methods inherited from class jltk.Component
activate, deactivate, focus, hasFocus, hide, init, istActive, isVisible, runMethodByName, setOnFocusGained, setOnFocusLost, show, toBack, toFront
-
-
-
-
Field Detail
-
fxShape
public javafx.scene.shape.Shape fxShape
-
lineColor
protected javafx.scene.paint.Color lineColor
-
fillColor
protected javafx.scene.paint.Color fillColor
-
transparancy
protected double transparancy
-
rotate
protected javafx.scene.transform.Rotate rotate
-
scale
protected javafx.scene.transform.Scale scale
-
xOffset
protected double xOffset
-
yOffset
protected double yOffset
-
x
protected double x
-
y
protected double y
-
-
Method Detail
-
init
protected void init(double pX, double pY, Window pWindow, javafx.scene.shape.Shape pShape)Basic initialisation, like setting postion and size, add the Element to the window. For some reason this cannot be solved using a constructor, because in subclasses the javaFX component must be initialised first. After this, init must be called.- Parameters:
pX- The horizontal coordinatepY- The vertical coordinatepWindow- The window on which the component should be placedpShape- The corresponding JavaFX-Component
-
getX
public double getX()
Return the x coordinate of this shape. It depends on the shape, what this coordinates discribe:- Circle: The center of the circle
- Rectangle: The upper left corner. (Rotated rechtangle: upper left corner of the bounding box)
-
getY
public double getY()
Return the y coordinate of upper left corner of the bounding box of this shape
-
getWidth
public double getWidth()
Return the width of this shape. This comes up to the width of the minimal rectangle surrounding this shape.- Returns:
- The width of the shape.
-
getHeight
public double getHeight()
Return the height of this shape. This comes up to the height of the minimal rectangle surrounding this shape.- Returns:
- The height of the shape.
-
setPosition
public void setPosition(double pX, double pY)Set the upper left corner of the shape to the specified position. If you might set the positon of the center of this shape, use #setCenterPosition(double, double)- Overrides:
setPositionin classComponent- Parameters:
pX- The x coordinate of the new positionpY- The y coordinate of the new position- See Also:
setCenterPosition(double,double),getX(),getY()
-
setCenterPosition
public void setCenterPosition(double pX, double pY)Set the center of the shape to the specified position. If you might set the positon of the upper left corner, use #setPosition(double, double)- Parameters:
pX- The x coordinate of the new positionpY- The y coordinate of the new position- See Also:
setPosition(double,double)
-
setFillColor
public void setFillColor(javafx.scene.paint.Color pColor)
The fill color of the shape will be changed to the specified color- Parameters:
pColor- the new fill color
-
setFillColor
public void setFillColor(String pColor)
The fill color of the shape will be changed to the specified color. As parameter you can use the color name from the javafx.scene.paint.Color field https://docs.oracle.com/javase/8/javafx/api/javafx/scene/paint/Color.html#field.summary For example setFillColor("ALICEBLUE") or setFillColor("blue").- Parameters:
pColor- the new fill color
-
setFillColor
public void setFillColor(double pRed, double pGreen, double pBlue)The fillcolor of the shape will be changed to specified rgb-color- Parameters:
pRed- the red proportion (must be between 0 and 1)pGreen- the green proportion (must be between 0 and 1)pBlue- the blue proportion (must be between 0 and 1)
-
setTransparancy
public void setTransparancy(double pValue)
Set the transparancy oh this shape to the specified value. pValue mus between 0.0 (not transparent) and 1.0 (transparent)- Parameters:
pValue- The new transparancy (between 0.0 and 1.0)- See Also:
getTransparancy()
-
getTransparancy
public double getTransparancy()
Return the transparancy of this shape. 0.0 means not transparent and 1.0 means full transparent- Returns:
- The transparency of this shape
-
flipHorizontal
public void flipHorizontal()
-
flipVertical
public void flipVertical()
-
move
public void move(double pDistance)
Moves this shape by the specified distance into the current direction, seesetRotation(double).- Parameters:
pDistance- The distance in pixel.
-
move
public void move(double pX, double pY)Move this shape by the specified x- and y-sections.- Parameters:
pX- The x distance in pixel.pY- The y distance in pixel.
-
scale
public void scale(double pScaleX, double pScaleY)Scale the shape with the specified factors. The scale centrum is the central position of this shape,#getCenterX()and#getCenterY()- Parameters:
pX- The scale factor for the x directionpY- The scale factor for the y direction
-
scaleTo
public void scaleTo(double pWidth, double pHeight)Scale the shape to the specified width and height.- Parameters:
pWidth- The new width of the shape.pHeight- The ne height of the shape.
-
setRotation
public void setRotation(double pAngle)
Set the rotation of this shape to the specified angle. Rotation is expressed as a degree value. Zero degrees is to the east (right-hand side of the window), and the angle increases clockwise.- Parameters:
pAngle- The angle in degrees
-
getRotation
public double getRotation()
Return the current rotation of this shape. Rotation is expressed as a degree value. Zero degrees is to the east (right-hand side of the window), and the angle increases clockwise.- Returns:
- The current rotation
-
turn
public void turn(double pAngle)
Turn this shape by the specified angle (in degrees). Zero degrees is to the east (right-hand side of the window), and the angle increases clockwise.- Parameters:
pAngle- The angle in degrees; positive values turn clockwise
-
turn
public void turn(double pX, double pY, double pAngle)Turn this schape by the specified angle (in degrees) arround the specified turning center Zero degrees is to the east (right-hand side of the window), and the angle increases clockwise.- Parameters:
pX- The x-coordinate of the turning point.pY- The y-coordinate of the turning point.pAngle- The angle in degrees; positive values turn clockwise
-
intersects
public boolean intersects(Shape pShape)
Return true, if this shape intersects the specified shape.- Parameters:
pShape- Another shape- Returns:
- true, if intersects, else false.
-
intersects
public static boolean intersects(Shape pShape1, Shape pShape2)
Return true, if the specified shapes intersects- Parameters:
pShape1- The first shapepShape2- The second shape- Returns:
- true, is shape1 and shape2 intersect.
-
contains
public boolean contains(Shape pShape)
Return true, if this shape fully includes the specified shape.- Parameters:
pShape- Another shape- Returns:
- true, if this shape contains the given. else false.
-
contains
public static boolean contains(Shape pOuter, Shape pInner)
Return true, if pOuter fully includes pInner.- Parameters:
pOuter- The outer shapepInner- The inner shape- Returns:
- true, if pOuter contains pInner.
-
contains
public boolean contains(double pX, double pY)Return true if the specified point is inside this shape.
-
setLineWidth
public void setLineWidth(double pLineWidth)
Set the width of the line/border to the specified value.- Parameters:
pLineWidth- The new line width
-
getLineWidth
public double getLineWidth()
Return the current used linewidth
-
setLineColor
public void setLineColor(javafx.scene.paint.Color pColor)
The line color of the shape will be changed to the specified color- Parameters:
pColor- The new line color
-
setLineColor
public void setLineColor(String pColor)
The line color of the shape will be changed to the specified color. As parameter you can use the color name from the javafx.scene.paint.Color field https://docs.oracle.com/javase/8/javafx/api/javafx/scene/paint/Color.html#field.summary For example setFillColor("ALICEBLUE") or setFillColor("blue").- Parameters:
pColor- the new line color
-
setLineColor
public void setLineColor(double pRed, double pGreen, double pBlue)The linecolor of the shape will be changed to specified rgb-color- Parameters:
pRed- the red proportion (must be between 0 and 1)pGreen- the green proportion (must be between 0 and 1)pBlue- the blue proportion (must be between 0 and 1)
-
delay
public void delay(long pMilliseconds)
Delay execution for this shape for the specfied number of milliseconds- Parameters:
pMilliseconds- Ein Parameter
-
-