package drawingBoard;
import javafx.beans.property.*;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.geometry.Orientation;
import javafx.scene.Cursor;
import javafx.scene.Group;
import javafx.scene.control.*;
import javafx.scene.effect.Bloom;
import javafx.scene.effect.InnerShadow;
import javafx.scene.effect.Light;
import javafx.scene.effect.Lighting;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.scene.text.Font;
import java.util.*;
public class PropertyBar extends Pane
{
MainPane fa;
private Label name = new Label("PROPERTY");
private ArrayList<ArrayList<Property>> objectProperty = new ArrayList<>();
private LinkedList<Shape> selected = new LinkedList<>();
private Shape nowShape;
private ScrollBar scrollBar = new ScrollBar();
private Group layout = new Group();
public ArrayList<ArrayList<Property>> getObjectProperty()
{
return objectProperty;
}
public Label getName()
{
return name;
}
public PropertyBar(MainPane fa)
{
scrollBar.setOrientation(Orientation.VERTICAL);
scrollBar.setPrefWidth(20);
scrollBar.layoutXProperty().bind(prefWidthProperty().subtract(scrollBar.getPrefWidth()));
scrollBar.prefHeightProperty().bind(heightProperty());
getChildren().add(scrollBar);
scrollBar.valueProperty().addListener((value, pre, now)->
{
layout.setLayoutY(-now.doubleValue());
});
setOnScroll(event ->
{
scrollBar.setValue(scrollBar.getValue()-event.getDeltaY());
});
setPrefWidth(250);
this.fa=fa;
setStyle("-fx-background-color: #ffffff");
Light.Point light = new Light.Point();
light.setColor(Color.BLACK);
light.xProperty().bind(widthProperty().divide(2));
light.yProperty().bind(heightProperty().divide(2));
light.setZ(300);
Lighting lighting = new Lighting();
lighting.setLight(light);
lighting.setSurfaceScale(50.0);
name.setFont(Font.font("Arial Black", 30));
name.setTextFill(Color.BLACK);
name.setLayoutX(40);
Group group = new Group(name);
group.setEffect(new Bloom(0.1));
layout.getChildren().add(group);
getChildren().add(layout);
}
public void initBind()
{
DragToSuit dragToSuit = new DragToSuit(Main.getChangeCursor());
this.setOnMouseEntered(dragToSuit);
this.setOnMouseExited(dragToSuit);
this.setOnMouseMoved(dragToSuit);
this.setOnMouseDragged(dragToSuit);
this.setOnMousePressed(dragToSuit);
this.setOnMouseReleased(dragToSuit);
}
public class DragToSuit implements EventHandler<MouseEvent>
{
private ChangeCursor changeCursor;
private boolean pressed = false;
public DragToSuit(ChangeCursor changeCursor)
{
this.changeCursor = changeCursor;
}
@Override
public void handle(MouseEvent event)
{
if(event.getEventType().equals(MouseEvent.MOUSE_ENTERED))
{
if(event.getX()<10)
{
Main.getScene().setCursor(Cursor.E_RESIZE);
}
}
else if(event.getEventType().equals(MouseEvent.MOUSE_EXITED))
{
Main.getScene().setCursor(changeCursor.future);
}
else if(event.getEventType().equals(MouseEvent.MOUSE_MOVED))
{
if(!pressed)
{
if (event.getX() >= 10)
{
Main.getScene().setCursor(changeCursor.future);
} else
{
Main.getScene().setCursor(Cursor.E_RESIZE);
}
}
}
else if(event.getEventType().equals(MouseEvent.MOUSE_PRESSED))
{
if(event.getX()<10)
{
pressed = true;
setPrefWidth(getWidth()-event.getX());
}
}
else if(event.getEventType().equals(MouseEvent.MOUSE_DRAGGED))
{
if(pressed)
{
setPrefWidth(getWidth()-event.getX());
}
}
else if(event.getEventType().equals(MouseEvent.MOUSE_RELEASED))
{
pressed = false;
}
}
}
public void setName(String name)
{
this.name.setText(name);
}
public void update(Shape shape)
{
delete(shape);
add(shape);
}
public void add(Shape shape)
{
add(shape, fa.getMyCenter().getObject().getChildren().indexOf(shape));
}
public void add(Shape shape, int index)
{
objectProperty.add(new ArrayList<>());
ArrayList<Property> now = objectProperty.get(index);
if(shape instanceof Line)//startX startY endX endY strokeWidth Color blendMode
{
Line line = (Line)shape;
now.add(shape.layoutXProperty());
now.add(shape.layoutYProperty());
now.add(line.startXProperty());
now.add(line.startYProperty());
now.add(line.endXProperty());
now.add(line.endYProperty());
now.add(line.strokeProperty());
now.add(line.rotateProperty());
now.add(line.strokeWidthProperty());
double x=line.endYProperty().getValue()-line.startYProperty().getValue();
double y=line.endXProperty().getValue()-line.startYProperty().getValue();
double width=line.strokeWidthProperty().doubleValue();
double length=Math.sqrt(x*x+y*y)*width;
Property area=new SimpleDoubleProperty(length);
Property perimeter=new SimpleDoubleProperty(2*(width+length));
now.add(area);
now.add(perimeter);
}
else if(shape instanceof CubicCurve)
{
CubicCurve curve = (CubicCurve)shape;
now.add(shape.layoutXProperty());
now.add(shape.layoutYProperty());
now.add(curve.startXProperty());
now.add(curve.startYProperty());
now.add(curve.endXProperty());
now.add(curve.endYProperty());
now.add(curve.controlX1Property());
now.add(curve.controlY1Property());
now.add(curve.controlX2Property());
now.add(curve.controlY2Property());
now.add(curve.strokeProperty());
now.add(curve.fillProperty());
now.add(curve.rotateProperty());
now.add(curve.strokeWidthProperty());
}
else if(shape instanceof Ellipse)
{
Ellipse ellipse = (Ellipse)shape;
now.add(shape.layoutXProperty());
now.add(shape.layoutYProperty());
now.add(ellipse.centerXProperty());
now.add(ellipse.centerYProperty());
now.add(ellipse.radiusXProperty());
now.add(ellipse.radiusYProperty());
now.add(ellipse.strokeProperty());
now.add(ellipse.fillProperty());
now.add(ellipse.rotateProperty());
now.add(ellipse.strokeWidthProperty());
if(ellipse.getRadiusX()==ellipse.getRadiusY()){
//System.out.println(ellipse.radiusXProperty());
SimpleDoubleProperty simpleDoubleProperty = new SimpleDoubleProperty(2 * Math.P
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
EasyDrawingBoard.zip (82个子文件)
EasyDrawingBoard.iml 572B
META-INF
MANIFEST.MF 56B
EasyDrawingBoard.jar 734KB
src
image
eraser.png 109KB
ellipse.png 2KB
chooser.png 2KB
cubiccurve.png 3KB
rectangle.png 590B
polyline.png 2KB
demo
BigWhite.png 157KB
ant.png 115KB
BigWhiteWithSword.png 115KB
antControl.png 10KB
sword.png 168KB
line.png 1KB
slf
Deserializer.java 13KB
SyntaxError.java 361B
drawingBoard
Board.java 5KB
PropertyBar.java 20KB
MyEraser.java 2KB
MenuBar.java 10KB
Geometry.java 10KB
MyRectangle.java 2KB
Tool.java 255B
MyEllipse.java 2KB
MyChooser.java 3KB
ChangeCursor.java 682B
MyPolyline.java 3KB
MyLine.java 1KB
MyCubicCurve.java 3KB
Cue.java 1KB
ToolBar.java 10KB
MainPane.java 2KB
Main.java 1KB
.idea
runConfigurations.xml 346B
misc.xml 278B
modules.xml 279B
workspace.xml 3KB
.gitignore 190B
libraries
javafx_sdk_17_0.xml 383B
javafx.xml 950B
artifacts
EasyDrawingBoard_jar.xml 582B
out
production
EasyDrawingBoard
image
eraser.png 109KB
ellipse.png 2KB
chooser.png 2KB
cubiccurve.png 3KB
rectangle.png 590B
polyline.png 2KB
demo
BigWhite.png 157KB
ant.png 115KB
BigWhiteWithSword.png 115KB
antControl.png 10KB
sword.png 168KB
line.png 1KB
slf
Deserializer.class 9KB
SyntaxError.class 738B
drawingBoard
PropertyBar$PointsProperty.class 3KB
MyEllipse.class 2KB
Board$1.class 1KB
MainPane.class 3KB
MyLine.class 2KB
ToolBar$DragToSuit.class 2KB
MenuBar.class 12KB
Board$GetPos.class 2KB
ToolBar.class 11KB
Geometry$Point.class 457B
Main.class 2KB
PropertyBar.class 20KB
MenuBar$LittleDeserializer.class 1KB
PropertyBar$DragToSuit.class 2KB
MyCubicCurve.class 3KB
ChangeCursor.class 1KB
Board$MoveProcessor.class 2KB
Tool.class 208B
MyChooser.class 5KB
MyPolyline.class 3KB
MyEraser.class 3KB
Cue.class 2KB
Geometry.class 8KB
MyRectangle.class 2KB
Board.class 6KB
artifacts
EasyDrawingBoard_jar
EasyDrawingBoard.jar 734KB
共 82 条
- 1
liu'1
- 粉丝: 4
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0