⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chartitem.java

📁 j2me is based on j2mepolish, client & server for mobile application. menu sample
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
					g.drawString( this.labelX, x + xAxisWidth, y, Graphics.RIGHT | Graphics.TOP  );
				//#endif
				y += this.font.getHeight() + this.paddingVertical;
				inout_params[1] = y;
			} else {
				//#if tmp.rotate
					//# g.drawString( this.labelX, x + xAxisWidth/2, y + this.contentHeight, Graphics.HCENTER | Graphics.BOTTOM  );
				//#else
					g.drawString( this.labelX, x + xAxisWidth, y + this.contentHeight, Graphics.RIGHT | Graphics.TOP  );
			//#endif
			}
		}
		if (this.labelY != null) {
			//#if tmp.rotate
				//# this.rotatedLabelY.paint(x, y + (yAxisHeight - this.rotatedLabelY.getHeight())/2, g);
				//# x += this.font.getHeight() + this.paddingHorizontal;
			//#else
			//#endif
		}
		
		// calculate baseline:
		int baseLineY;
		if (this.dataMaximum > 0) {
			baseLineY = y + ((this.dataMaximum - this.baseLine) * this.scaleFactorY) / 100;
		} else {
			baseLineY = y + (this.baseLine * this.scaleFactorY) / 100;
		}

		// draw axis:
		g.setColor( this.axisColor );
		g.drawLine( x, baseLineY, x + xAxisWidth,  baseLineY );
		g.drawLine( x, y, x, y +  yAxisHeight );
		
		x++;
		inout_params[0] = x;
		
		return baseLineY;
	}

	/* (non-Javadoc)
	 * @see de.enough.polish.ui.FakeCustomItem#paintContent(int, int, int, int, javax.microedition.lcdui.Graphics)
	 */
	protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {
		// TODO robertvirkus cache diagram in an image at least on nokia-ui-api and MIDP 2.0+ devices
		int[][] sequences = this.dataSequences;
		if (sequences == null) {
			return;
		}
		
		int[] inout_params = new int[]{ x, y };
		int baseLineY = paintGrid(x, y, leftBorder, rightBorder, inout_params, g); 
		x = inout_params[0];
		y = inout_params[1];

		// draw data:
		for (int i = 0; i < sequences.length; i++) {
			g.setColor( this.colors[i] );
			int[] dataRow = sequences[i];
			if (dataRow == null || dataRow.length == 0) {
				continue;
			}
			int lastDatumX = x;
			int lastDatumY = baseLineY - (dataRow[0] * this.scaleFactorY) / 100; 
			for (int j = 1; j < dataRow.length; j++) {
				int datum = dataRow[j];
				int datumX = x + (j * this.scaleFactorX) / 100;
				int datumY = baseLineY - (datum * this.scaleFactorY) / 100;
				g.drawLine(  lastDatumX, lastDatumY, datumX, datumY);
				lastDatumX = datumX;
				lastDatumY  = datumY;
			}				
		}
	}
	
	

	/* (non-Javadoc)
	 * @see de.enough.polish.ui.FakeCustomItem#setStyle(de.enough.polish.ui.Style)
	 */
	public void setStyle(Style style) {
		super.setStyle(style);
		this.font = style.font;
		this.fontColor = style.getFontColor();
	}

	/**
	 * @return the baseLine
	 */
	public int getBaseLine() {
		return this.baseLine;
	}

	/**
	 * @param baseLine the baseLine to set
	 */
	public void setBaseLine(int baseLine) {
		this.baseLine = baseLine;
	}

	/**
	 * @return the dataMaximum
	 */
	public int getDataMaximum() {
		return this.dataMaximum;
	}

	/**
	 * @param dataMaximum the dataMaximum to set
	 */
	public void setDataMaximum(int dataMaximum) {
		this.dataMaximum = dataMaximum;
	}

	/**
	 * @return the dataMinimum
	 */
	public int getDataMinimum() {
		return this.dataMinimum;
	}

	/**
	 * @param dataMinimum the dataMinimum to set
	 */
	public void setDataMinimum(int dataMinimum) {
		this.dataMinimum = dataMinimum;
	}

	/**
	 * @return the dataSequences
	 */
	public int[][] getDataSequences() {
		return this.dataSequences;
	}

	/**
	 * Sets the data that should be visualized.
	 * Also the minimum and maximum of the data is calculated here.
	 * 
	 * @param dataSequences the dataSequences to set
	 */
	public void setDataSequences(int[][] dataSequences) {
		this.dataSequences = dataSequences;
		if (dataSequences == null || (dataSequences.length == 0) ) {
			this.dataMaximum = this.dataMinimum = 0;
		} else {
			int min = Integer.MAX_VALUE;
			int max = Integer.MIN_VALUE;
			for (int i = 0; i < dataSequences.length; i++) {
				int[] dataRow = dataSequences[i];
				for (int j = 0; j < dataRow.length; j++) {
					int datum = dataRow[j];
					if (datum < min) {
						min = datum;
					}
					if (datum > max) {
						max = datum;
					}
				}				
			}
			this.dataMaximum = max;
			this.dataMinimum = min;
			if (this.colors == null) {
				this.colors = new int[ this.dataSequences.length ];
			}
		}
	}

	/**
	 * @return the divider
	 */
	public int getDivider() {
		return this.divider;
	}

	/**
	 * @param divider the divider to set
	 */
	public void setDivider(int divider) {
		this.divider = divider;
	}

	/**
	 * @return the labelsData
	 */
	public String[] getLabelsData() {
		return this.labelsData;
	}

	/**
	 * @param labelsData the labelsData to set
	 */
	public void setLabelsData(String[] labelsData) {
		this.labelsData = labelsData;
	}

	/**
	 * @return the labelX
	 */
	public String getLabelX() {
		return this.labelX;
	}

	/**
	 * @param labelX the labelX to set
	 */
	public void setLabelX(String labelX) {
		this.labelX = labelX;
	}

	/**
	 * @return the labelY
	 */
	public String getLabelY() {
		return this.labelY;
	}

	/**
	 * @param labelY the labelY to set
	 */
	public void setLabelY(String labelY) {
		//#if tmp.rotate
			//# this.rotatedLabelY = null; 
			//# this.isInitialized = false;
		//#endif
		this.labelY = labelY;
	}

	/**
	 * @return the axisColor
	 */
	public int getAxisColor() {
		return this.axisColor;
	}

	/**
	 * @param axisColor the axisColor to set
	 */
	public void setAxisColor(int axisColor) {
		this.axisColor = axisColor;
	}

	/**
	 * @return the colors
	 */
	public int[] getColors() {
		return this.colors;
	}

	/**
	 * @param colors the colors to set
	 */
	public void setColors(int[] colors) {
		this.colors = colors;
	}

	/**
	 * Retrieves the scale factor used by the default implementation.
	 * This method is usually only interesting for specifc chart ItemViews.
	 *  
	 * @return the vertical scale factor
	 */
	public int getScaleFactorY() {
		return this.scaleFactorY;
	}
	
	/**
	 * Retrieves the scale factor used by the default implementation.
	 * This method is usually only interesting for specifc chart ItemViews.
	 *  
	 * @return the honrizontal scale factor
	 */
	public int getScaleFactorX() {
		return this.scaleFactorX;
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -