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

📄 theme.java

📁 最强手机阅读器Anyview3.0版的界面代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			g.drawRect(x, y, width - 1, 19);
		}
	}

	/**
	 * 绘制下拉框
	 * @param g
	 * @param x
	 * @param y
	 * @param width
	 */
	public static void drawDropList(Graphics g, int x, int y, int width) {
		if (width < 20) {
			width = 20;
		}
		if (COMPLEX_THEME) {
			g.drawImage(InputLeft, x, y, LEFTTOP);
			int rest = width - 20;
			int left = x + 2;
			while (rest > 0) {
				if (rest < 10) {
					g.drawImage(InputCenter, left + rest - 10, y, LEFTTOP);
				} else {
					g.drawImage(InputCenter, left, y, LEFTTOP);
				}
				rest -= 10;
				left += 10;
			}
			g.drawImage(DropArrow, x + width - 18, y, LEFTTOP);
			g.drawImage(InputRight, x + width - 2, y, LEFTTOP);
		} else {
			g.setColor(Background);
			g.fillRect(x, y, width, 20);
			g.setColor(TextColor);
			g.drawRect(x, y, width - 1, 20 - 1);
		}
	}

	/**
	 * 绘制滚动条
	 * @param g
	 * @param x
	 * @param y
	 * @param height
	 */
	public static void drawScrollBarFront(Graphics g, int x, int y, int height) {
		if (height < 16) {
			height = 16;
		}
		if (COMPLEX_THEME) {
			g.drawImage(ScrollBarUp, x, y, LEFTTOP);
			int rest = height - 3;
			int top = y + 2;
			while (rest > 0) {
				if (rest < 8) {
					g.drawImage(ScrollBarCenter, x, top + rest - 8, LEFTTOP);
				} else {
					g.drawImage(ScrollBarCenter, x, top, LEFTTOP);
				}
				top += 8;
				rest -= 8;
			}
			g.drawImage(ScrollBarDown, x, y + height - 1, LEFTTOP);
		} else {
			g.setColor(ComponentLight);
			g.fillRect(x, y, 8, height - 1);
			g.setColor(ComponentDark);
			g.drawRect(x, y, 8, height - 1);
		}
	}

	/**
	 * 绘制滚动条阴影部分
	 * @param g
	 * @param x
	 * @param y
	 * @param height
	 */
	public static void drawScrollBarShade(Graphics g, int x, int y, int height) {
		if (height < 16) {
			height = 16;
		}
		if (COMPLEX_THEME) {
			int rest = height;
			int top = y;
			while (rest > 0) {
				if (rest < 8) {
					g.drawImage(ScrollBarShade, x, top + rest - 8, LEFTTOP);
				} else {
					g.drawImage(ScrollBarShade, x, top, LEFTTOP);
				}
				top += 8;
				rest -= 8;
			}
		} else {
			g.setColor(Background);
			g.fillRect(x, y, 8, height);
			g.setColor(ComponentDark);
			g.drawRect(x, y, 8, height);
		}
	}

	/**
	 * 绘制标题栏
	 * @param g
	 * @param x
	 * @param y
	 * @param width
	 */
	public static void drawTitleBar(Graphics g, int x, int y, int width) {
		if (width < 20) {
			width = 20;
		}
		if (COMPLEX_THEME) {
			int rest = width;
			int left = x;
			while (rest > 0) {
				if (rest < 10) {
					g.drawImage(BarCenter, left + rest - 10, y, LEFTTOP);
				} else {
					g.drawImage(BarCenter, left, y, LEFTTOP);
				}
				rest -= 10;
				left += 10;
			}
		} else {
			g.setColor(TitleBackground);
			g.fillRect(x, y, width, 20);
			g.setColor(TextColor);
			g.drawRect(x - 1, y, width + 1, 19);
		}
	}

	public static void drawArrow(Graphics g, Image img, int x, int y, int dir) {
		switch (dir) {
		case UP:
			g.drawImage(img, x, y, LEFTTOP);
			break;
		case RIGHT:
			g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT90, x, y,
					LEFTTOP);
			break;
		case DOWN:
			g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT180, x, y,
					LEFTTOP);
			break;
		case LEFT:
			g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT270, x, y,
					LEFTTOP);
			break;
		}
	}

	public static void drawArrow(Graphics g, int x, int y, int dir, int color) {
		int[] colors = arrowArray; /*new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1,
		 1, 1, 1, 1, 1, 1 };*/
		for (int i = 0; i < colors.length; i++) {
			if (colors[i] != 0) {
				colors[i] = color;
			}
		}
		Image img = Image.createRGBImage(colors, 7, 4, SupportAlpha);
		switch (dir) {
		case UP:
			g.drawImage(img, x, y, LEFTTOP);
			break;
		case RIGHT:
			g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT90, x, y,
					LEFTTOP);
			break;
		case DOWN:
			g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT180, x, y,
					LEFTTOP);
			break;
		case LEFT:
			g.drawRegion(img, 0, 0, img.getWidth(), img.getHeight(), Sprite.TRANS_ROT270, x, y,
					LEFTTOP);
			break;
		}
		img = null;
		colors = null;
	}

	public static void drawSelectedBackground(Graphics g, int x, int y, int width, int height) {
		if (COMPLEX_THEME) {
			int[] line = generateTransitionalColor(TextShade, TransEnd, width);
			Image lineImg = Image.createRGBImage(line, line.length, 1, false);
			for (int i = 0; i < height; i++) {
				g.drawImage(lineImg, x, y + i, LEFTTOP);
			}
		} else {
			g.setColor(TextShade);
			g.fillRect(x, y, width, height);
		}
	}

	/**
	 * 绘制radio button
	 * @param g
	 * @param x
	 * @param y
	 * @param type 单选/复选
	 * @param checked 是否被选中
	 */
	public static void drawRadioElement(Graphics g, int x, int y, boolean type, boolean checked) {
		if (checked) {
			if (type) {
				g.drawImage(Radios[0], x, y, LEFTTOP);
				//				g.setColor(Theme.TextShade);
				//				g.drawArc(x + 3, y + 3, 10, 10, 0, 360);
				//				g.fillArc(x + 5, y + 5, 7, 7, 0, 360);
			} else {
				g.drawImage(Radios[2], x, y, LEFTTOP);
				//				g.setColor(Theme.TextShade);
				//				g.drawRect(x, y, 10, 10);
				//				g.fillRect(x, y, 7, 7);
			}
		} else {
			if (type) {
				//				g.setColor(Theme.TextShade);
				//				g.drawArc(x + 3, y + 3, 10, 10, 0, 360);
				g.drawImage(Radios[1], x, y, LEFTTOP);
			} else {
				//				g.setColor(Theme.TextShade);
				//				g.drawRect(x, y, 10, 10);
				g.drawImage(Radios[3], x, y, LEFTTOP);
			}
		}

	}
	
	public static void paintBusyFrame(Graphics g, int index, int px, int py) {
		g.setColor(ComponentDark);
		g.drawRect(px, py, 8, 8);
		g.drawRect(px + 12, py, 8, 8);
		g.drawRect(px, py + 12, 8, 8);
		g.drawRect(px + 12, py + 12, 8, 8);

		g.setColor(Background);
		g.fillRect(px + 1, py + 1, 7, 7);
		g.fillRect(px + 13, py + 1, 7, 7);
		g.fillRect(px + 1, py + 13, 7, 7);
		g.fillRect(px + 13, py + 13, 7, 7);

		g.setColor(ComponentDark);
		switch (index) {
		case 0:			
			g.fillRect(px + 1, py + 1, 7, 7);
			break;
		case 1:
			g.fillRect(px + 13, py + 1, 7, 7);
			break;
		case 2:
			g.fillRect(px + 13, py + 13, 7, 7);
			break;
		case 3:
			g.fillRect(px + 1, py + 13, 7, 7);
			break;
		}
	}

	public static int[] generateTransitionalColor(int color1, int color2, int steps) {
		int[] color1RGB = retrieveRGBComponent(color1);
		int[] color2RGB = retrieveRGBComponent(color2);

		if (steps < 3 || color1RGB == null || color2RGB == null)
			return null;

		int[] colors = new int[steps];
		colors[0] = color1;
		colors[colors.length - 1] = color2;

		steps = steps - 2;
		int redDiff = color2RGB[0] - color1RGB[0];
		int greenDiff = color2RGB[1] - color1RGB[1];
		int blueDiff = color2RGB[2] - color1RGB[2];

		//from the second to the last second.
		for (int i = 1; i < colors.length - 1; i++) {
			colors[i] = generateFromRGBComponent(new int[] { color1RGB[0] + redDiff * i / steps,
					color1RGB[1] + greenDiff * i / steps, color1RGB[2] + blueDiff * i / steps });
		}

		return colors;
	}

	public static int[] retrieveRGBComponent(int color) {
		int[] rgb = new int[3];

		rgb[0] = (color & 0x00ff0000) >> 16;
		rgb[1] = (color & 0x0000ff00) >> 8;
		rgb[2] = (color & 0x000000ff);

		return rgb;
	}

	public static int generateFromRGBComponent(int[] rgb) {
		if (rgb == null || rgb.length != 3 || rgb[0] < 0 || rgb[0] > 255 || rgb[1] < 0
				|| rgb[1] > 255 || rgb[2] < 0 || rgb[2] > 255)
			return 0xfffff;

		return rgb[0] << 16 | rgb[1] << 8 | rgb[2];

	}
}

⌨️ 快捷键说明

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