1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
package org.spc.ofp.guifx.skin.basic;
import org.spc.ofp.guifx.skin.SeparatorSkin;
import javafx.scene.shape.Line;
import org.spc.ofp.guifx.Separator;
import org.spc.ofp.gui.Orientation;
import org.spc.ofp.guifx.skin.basic.BasicLnFConstants;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import org.spc.ofp.guifx.UIUtilities;
/**
* Basic implementation of a separator.
* @author Fabrice Bouyé (fabriceb@spc.int)
*/
public class BasicSeparatorSkin extends SeparatorSkin {
/**
* Source control.
*/
def separatorControl:Separator = bind control as Separator;
/**
* Orientation of the separator.
*/
var orientation:Orientation = bind separatorControl.orientation on replace {
//println("BasicSeparatorSkin:orientation {orientation} on separator {separatorControl.id}");
}
/**
* Length of the separator.
*/
var length:Number = bind separatorControl.length on replace {
//println("BasicSeparatorSkin:length {length} on separator {separatorControl.id}");
}
/**
* Color of the separator.
*/
var color:Color = bind separatorControl.color;
/**
* Color of the separator.
*/
var shadowColor:Color = bind separatorControl.shadowColor;
def strokeWidth:Number = BasicLnFConstants.SEPARATOR_STROKE_SIZE;
def line:Line = Line {
stroke: bind UIUtilities.createTwinFadingGradient(color, orientation);
strokeWidth: strokeWidth;
startX: 0;
startY: 0;
endX: bind if (orientation == Orientation.VERTICAL) { 0 } else { length };
endY: bind if (orientation == Orientation.VERTICAL) { length } else { 0 };
}
def shadow:Line = Line {
stroke: bind UIUtilities.createTwinFadingGradient(shadowColor, orientation);
opacity: 0.33
strokeWidth: strokeWidth;
startX: bind if (orientation == Orientation.VERTICAL) { strokeWidth } else { 0 };
startY: bind if (orientation == Orientation.VERTICAL) { 0 } else { strokeWidth };
endX: bind if (orientation == Orientation.VERTICAL) { strokeWidth } else { length };
endY: bind if (orientation == Orientation.VERTICAL) { length } else { strokeWidth };
}
/**
* {@inheritDoc}
*/
init {
node = Group {
// Need to cache because gradients are still somewhat fucked up in 1.2.1 release.
cache: true;
content: [ line, shadow ]
}
}
/**
* {@inheritDoc}
*/
override function getPrefWidth(height: Number): Number {
return node.boundsInLocal.width;
}
/**
* {@inheritDoc}
*/
override function getPrefHeight(width: Number): Number {
return node.boundsInLocal.height;
}
/**
* {@inheritDoc}
*/
public override function contains(localX:Number, localY:Number):Boolean {
return node.contains(localX, localY);
}
/**
* {@inheritDoc}
*/
public override function intersects(localX: Number, localY:Number, localWidth:Number, localHeight:Number):Boolean {
return node.intersects(localX, localY, localWidth, localHeight);
}
} |
Partager