java直角坐标系_Java2d画直角坐标系

最近项目用到java作图,首先想到的是利用开源插件jfreechart,文档收费,网上资料参差不齐,最后还是觉得采用java2D bufferedImage作图。 现在分享一下。

把一张图片分为border部分和主体部分,如下图所示:

aa9dadbca1e4b2bdf946182f0e1f7b01.png

定义一个边界类

/**

* Copyright (c) 2014, alax

* All Rights Reserved.

*/

package chapterOne.axis;

/**

*

* @author alax_app@yeah.net

* @Date 2014-3-18 下午11:41:10

*

*/

public class AxisBorder {

private int left;

private int right;

private int top;

private int bottom;

private int backgroundColor;//背景色

public AxisBorder(){

}

public AxisBorder(int left, int right, int top, int bottom,

int backgroundColor) {

super();

this.left = left;

this.right = right;

this.top = top;

this.bottom = bottom;

this.backgroundColor = backgroundColor;

}

public int getLeft() {

return left;

}

public void setLeft(int left) {

this.left = left;

}

public int getRight() {

return right;

}

public void setRight(int right) {

this.right = right;

}

public int getTop() {

return top;

}

public void setTop(int top) {

this.top = top;

}

public int getBottom() {

return bottom;

}

public void setBottom(int bottom) {

this.bottom = bottom;

}

public int getBackgroundColor() {

return backgroundColor;

}

public void setBackgroundColor(int backgroundColor) {

this.backgroundColor = backgroundColor;

}

}

接下来定义坐标轴实例

/**

* Copyright (c) 2014, alax

* All Rights Reserved.

*/

package chapterOne.axis;

import java.util.Date;

/**

*

* @author alax_app@yeah.net

* @Date 2014-3-19 上午12:10:01

*

*/

public class Axis {

public static final String VALUE = "value";

public static final String DATETIME = "datetime";

private int lineColor;//y轴颜色

private int lineWidth;//y轴宽度

private String title;//y轴标题

private String type;//y轴类型 支持value 类型 和datetime类型

private double max;//最大值

private double min;//最小值

private int ticks;//刻度个数

private Date startDate;

private Date endDate;

private String labelFormat; //刻度值排版

public Axis(){

}

public Axis(int lineColor, int lineWidth, String title, String type,

double max, double min, int ticks, Date startDate, Date endDate,

String labelFormat) {

super();

this.lineColor = lineColor;

this.lineWidth = lineWidth;

this.title = title;

this.type = type;

this.ma

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值