Paint.zip

  • 橙子cheng
    了解作者
  • Java
    开发工具
  • 72KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2020-12-22 23:03
    上传日期
(1)在画布上绘制直线、曲线、矩形、椭圆等图形 (2)实现输入文字,橡皮擦 (3)可以绘制填充图形以及设置画笔的颜色和粗细 (4)实现撤销操作、保存图片
Paint.zip
  • Paint
  • bin
  • MyPaint
  • MyRectangle.class
    4.8KB
  • MyStraitLine.class
    4KB
  • WRObject2File.class
    3KB
  • package-info.class
    113B
  • ToolsPane.class
    15.5KB
  • Main.class
    10.6KB
  • MyCircle.class
    4KB
  • winattr.class
    949B
  • Copy.class
    574B
  • MySquare.class
    613B
  • MyCanvas.class
    14.1KB
  • MyText.class
    4.6KB
  • MyPolygon.class
    4.7KB
  • ButtonStyle.class
    1.1KB
  • MyEllipse.class
    4.3KB
  • resources
  • line_8px.png
    827B
  • line_1px.png
    174B
  • line_10px.png
    831B
  • line_3px.png
    807B
  • ellipse_16px.png
    799B
  • triangle_16px.png
    872B
  • paint.png
    1.7KB
  • square_16px.png
    716B
  • line_13px.png
    837B
  • exit_16px.png
    857B
  • straitline_16px.png
    719B
  • openfile_16px.png
    1KB
  • information_24px.png
    1KB
  • savefile_16px.png
    892B
  • file_24px.png
    1KB
  • randomline_16px.png
    817B
  • line_5px.png
    816B
  • text_16px.png
    802B
  • rectangle_16px.png
    780B
  • line_16px.png
    821B
  • circle_16px.png
    815B
  • .settings
  • org.eclipse.jdt.core.prefs
    592B
  • src
  • MyPaint
  • Main.java
    8.2KB
  • ToolsPane.java
    13.8KB
  • winattr.java
    3KB
  • MyCanvas.java
    12.5KB
  • MyShape.java
    24.4KB
  • package-info.java
    61B
  • .classpath
    2.2KB
  • .project
    381B
内容介绍
package MyPaint; import java.io.Serializable; import java.util.Date; import javafx.event.EventHandler; import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.Circle; import javafx.scene.shape.Ellipse; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.scene.shape.Rectangle; import javafx.scene.shape.Shape; import javafx.scene.text.Font; import javafx.scene.text.Text; interface Copy{ public Shape deepCopy(double x, double y); public Shape deepCopy(double... points); public double getPosX(); public double getPosY(); public double getArea(); public double getPerimeter(); public double[] getPos(); public String getID(); public double getwidth(); public double getheight(); public String getLineColor(); public String getFillColor(); public double getLineWidth(); public Shape reply(); public void changeAttr(double lineWidth, Paint lineColor, Paint fillColor); } class MyStraitLine extends Line implements Serializable, Copy{ protected Date createDate; protected double[] pos; protected double lineWidth; protected String lineColor; protected String fillColor; public MyStraitLine(double startX, double startY, double endX, double endY, double lineWidth, Paint lineColor, Paint fillColor) { super(startX, startY, endX, endY); this.setStrokeWidth(lineWidth); this.setStroke(lineColor); this.setFill(fillColor); this.pos = new double[] {startX, startY, endX, endY}; this.createDate = new Date(); this.lineWidth = lineWidth; this.lineColor = (lineColor==null?"":((Color)lineColor).toString() ); this.fillColor = (fillColor==null?"":((Color)fillColor).toString() ); } @Override public Shape deepCopy(double x, double y) { // TODO Auto-generated method stub double offsetX = x-this.pos[0]; double offsetY = y-this.pos[1]; MyStraitLine newCircle = new MyStraitLine(x,y,this.pos[2]+offsetX, this.pos[3]+offsetY, this.getStrokeWidth(), this.getStroke(), this.getFill()); return newCircle; } @Override public Shape deepCopy(double... points) { // TODO Auto-generated method stub return this.deepCopy(points[0], points[1]); } @Override public double getPosX() { // TODO Auto-generated method stub return this.pos[0]; } @Override public double getPosY() { // TODO Auto-generated method stub return this.pos[1]; } @Override public double[] getPos() { // TODO Auto-generated method stub return this.pos; } @Override public String getID() { // TODO Auto-generated method stub return "MyStraitLine@"+this.createDate.getTime(); } @Override public double getwidth() { // TODO Auto-generated method stub return 0; } @Override public double getheight() { // TODO Auto-generated method stub return 0; } @Override public String getLineColor() { // TODO Auto-generated method stub return this.lineColor; } @Override public String getFillColor() { // TODO Auto-generated method stub return this.fillColor; } @Override public double getLineWidth() { // TODO Auto-generated method stub return this.lineWidth; } @Override public Shape reply() { // TODO Auto-generated method stub Paint fill = this.fillColor.equals("")?null:Color.valueOf(this.fillColor); Paint lineColor = this.lineColor.equals("")?null:Color.valueOf(this.lineColor); MyStraitLine newShape = new MyStraitLine(this.getPosX(), this.getPosY(), this.pos[2], this.pos[3], this.lineWidth, lineColor, fill); newShape.createDate = this.createDate; return newShape; } public String toString() { return this.getID()+"[ pos=[startX="+(int)this.getPosX()+"," + " StartY="+(int)this.getPosY()+", endX="+(int)this.pos[2]+", endY="+(int)this.pos[3]+"] length="+(int)this.getPerimeter()+ ", strokeWidth="+(int)this.lineWidth+", stroke="+this.lineColor+", fill="+this.fillColor+"]"; } @Override public double getArea() { // TODO Auto-generated method stub return 0; } @Override public double getPerimeter() { // TODO Auto-generated method stub return Math.sqrt((this.pos[0]-this.pos[2])*(this.pos[0]-this.pos[2]) + (this.pos[1]-this.pos[3])*(this.pos[1]-this.pos[3])); } @Override public void changeAttr(double lineWidth, Paint lineColor, Paint fillColor) { // TODO Auto-generated method stub this.setStrokeWidth(lineWidth); this.setStroke(lineColor); this.setFill(fillColor); this.lineWidth = lineWidth; this.lineColor = (lineColor==null?"":((Color)lineColor).toString() ); this.fillColor = (fillColor==null?"":((Color)fillColor).toString() ); } } class MyRectangle extends Rectangle implements Serializable, Copy{ /** * */ private static final long serialVersionUID = -8577986604588650981L; protected Date createDate; protected double[] pos; protected double width, height, lineWidth; protected String lineColor; protected String fillColor; public MyRectangle(double x, double y, double width, double height, double lineWidth, Paint lineColor, Paint fillColor) { super(x,y,width,height); this.setFill(fillColor); this.setStrokeWidth(lineWidth); this.setStroke(lineColor); this.pos = new double[] {x,y}; this.createDate = new Date(); this.width = width; this.height = height; this.lineWidth = lineWidth; this.lineColor = (lineColor==null?"":((Color)lineColor).toString() ); this.fillColor = (fillColor==null?"":((Color)fillColor).toString() ); } public double[] getPos() { return this.pos; } public double getPosX() { return this.pos[0]; } public double getPosY() { return this.pos[1]; } public double getArea() { return (int)this.getWidth() * (int)this.getHeight(); } public double getPerimeter() { return ( (int)this.getWidth() + (int)this.getHeight() ) * 2; } public Date getDate() { return this.createDate; } //使用创建时的秒数来唯一标记形状 public String getID() { return "MyRectangle@"+this.createDate.getTime(); } public MyRectangle deepCopy(double x, double y) { MyRectangle newRect = new MyRectangle(x, y, this.getWidth(), this.getHeight(), this.getStrokeWidth(), this.getStroke(), this.getFill()); return newRect; } @Override public Shape deepCopy(double... points) { // TODO Auto-generated method stub return this.deepCopy(points[0], points[1]); } public Shape reply() { Paint fill = this.fillColor.equals("")?null:Color.valueOf(this.fillColor); Paint lineColor = this.lineColor.equals("")?null:Color.valueOf(this.lineColor); MyRectangle newShape = new MyRectangle(this.getPosX(), this.getPosY(), this.getwidth(), this.getheight(), this.lineWidth, lineColor, fill); newShape.createDate = this.createDate; return newShape; } public String toString() { return this.getID()+"[ pos=[x="+(int)this.getPosX()+", y="+(int)this.getPosY()+"] width="+(int)this.width+", height="+(int)this.height+ ", area="+(int)this.getArea()+", perimeter="+(int)this.getPerimeter()+ ", strokeWidth="+(int)this.lineWidth+", stroke="+this.lineColor+", fill="+this.fillColor+"]"; } @Override public String getLineColor() { // TODO Auto-generated method stub return this.lineColor; } @Override public String getFillColor() { // TODO Auto-generated method stub return this.fillColor; } @Override public double getLineWidth() { // TODO Auto-generated method stub return this.lineWidth; } @Override public double getwidth() { // TODO Auto-generated method stub return this.width; } //@Override public double getheight() { // TODO Auto-generated method stub return this.height; } @Override public void changeAttr(double lineWidth, Paint lineColor, Paint fillColor) { // TODO Auto-generated method
评论
    相关推荐
    • c#画图软件
      c#画图软件,非常好用的有源代码的哦;记得好好看哦!
    • gnuplot画图软件
      gnuplot画图软件
    • mfc画图软件
      c++的mfc的画图软件,含代码。适合新手学习使用
    • 3DMax制图软件
      3D制图软件,简单、易用,运行环境:win7.3DS Max 全称3D Studio Max,是Autodesk公司开发的三维动画制作和渲染软件(Autodesk AutoCAD 2010也是Autodesk公司的软件产品)3DS Max广泛应用于广告、影视、工业设计、...
    • 画图软件SmartDraw
      非常实用的一款画图软件,简单易学好用,功能强大,可用于画出漂亮的流程图,网络结构图等
    • EastDraw 画图软件
      一款多文档模式GDI画图学习软件。 运用MFC框架开发,有专门的画图工具栏。是一款学习VC++的好源码。
    • PCB画图软件
      Sprint-Layout 是一种PCB画板/抄板DIY软件,比AD和protel简单易用。  软件由 tplin 根据 Sprint-Layout 6.0 德文20140310注册版汉化修改,绿色版由 FJXM-P 整理绿化,在XP 32系统下测试通过。
    • delphi画图软件
      delphi的开源画图软件,可以使用,非本人编写,希望可以加入分层和拖动功能
    • Java画图软件
      运用Java编程模拟画图软件。实现画线条,矩形,椭圆,等图形,功能:保存文件,选择颜色等...
    • android画图软件
      基于android的画图软件,可以绘画,上传,变颜色,变画笔,插销等等操作