Subversion Repository Public Repository

Aurocare_27_07_2018

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcarecommonutil.util;

/**
 *
 * @author user3
 */


import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.GeneralPath;
import javax.swing.ImageIcon;
import javax.swing.JPanel;



// TODO: Auto-generated Javadoc
/**
 * The Class UserInputsPanel.
 */
public class UserInputsPanel extends javax.swing.JPanel {

	/** The start color. */
	private Color startColor = new Color(238, 238, 238);
	
	/** The end color. */
	private Color endColor = new Color(255, 255, 255);
	
	/** The path. */
	GeneralPath path;
	
	/** The accent color. */
	Color accentColor = new Color(0x80ffffff);
	
	/** The text color. */
	Color textColor = new Color(0x0f0f0f);
	
	/** The title. */
	String title;

	/**
	 * Instantiates a new user inputs panel.
	 */
	public UserInputsPanel() {
		super();

	}

	/**
	 * Instantiates a new user inputs panel.
	 *
	 * @param color1 the color1
	 * @param color2 the color2
	 */
	public UserInputsPanel(Color color1, Color color2) {
		super();
		startColor = color1;
		endColor = color2;

	}

	/**
	 * Override the default paintComponent method to paint the gradient in the
	 * panel.
	 *
	 * @param g the g
	 */
	public void paintComponent(Graphics g) {
		Graphics2D g2d = (Graphics2D) g.create();
		int h = getHeight();
		int w = getWidth();
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);

		/** 
		 * Top Polygon
		 */
		GeneralPath path = new GeneralPath();
		path.moveTo(70, 0);
		path.lineTo(8, 0);
		path.quadTo(0, 0, 0, 7);
		path.lineTo(0, 55);
		path.lineTo(getWidth() - 1, 55);
		path.lineTo(getWidth() - 1, 7);
		path.quadTo(getWidth() - 1, 0, getWidth() - 8, 0);
		path.lineTo(30, 0);

		Rectangle bounds1 = path.getBounds();
		GradientPaint painter = new GradientPaint(0, path.getBounds().y,
				true ? endColor : startColor, 0,
				bounds1.y + bounds1.height - 1, true ? startColor : endColor);
		g2d.setPaint(painter);
		g2d.fill(path);
		Rectangle rectangle = new Rectangle(0, 40, getWidth(), 20);
		g2d.fill(rectangle);
		g2d.setColor(new Color(128, 128, 128));
		g2d.draw(path);

		/**
		 * Middle Rectangle 
		 */
		g2d.setPaint(new Color(240, 240, 240));
		g2d.fillRect(0, 31, getWidth() - 1, h - 50);
		g2d.setColor(new Color(128, 128, 128));
		g2d.drawLine(12, 0, getWidth() - 10, 0);
		g2d.drawRect(0, 30, getWidth() - 1, h - 50);

		/**
		 * Bottom Polygon
		 */
		h = h - 30;
		path = new GeneralPath();
		path.moveTo(0, h);
		path.lineTo(0, h + 22);
		path.quadTo(0, h + 29, 8, h + 29);
		path.lineTo(getWidth() - 8, h + 29);
		path.quadTo(getWidth() - 1, h + 29, getWidth() - 1, h + 22);
		path.lineTo(getWidth() - 1, h);
		g2d.setColor(Color.GRAY);
		startColor = new Color(192, 192, 192);
		endColor = new Color(238, 238, 238);
		bounds1 = path.getBounds();
		painter = new GradientPaint(0, path.getBounds().y, endColor, 0,
				bounds1.y + bounds1.height - 1, startColor);
		g2d.setPaint(painter);
		g2d.fill(path);
		g2d.setColor(new Color(128, 128, 128));
		g2d.draw(path);
		g2d.setColor(new Color(128, 128, 128));
		g2d.drawLine(0, h - 1, getWidth() - 1, h - 1);

		/**
		 *  Title
		 */
		g2d.setFont(g2d.getFont().deriveFont(Font.BOLD).deriveFont(
				(float) g2d.getFont().getSize() + 1));

		g2d.setColor(accentColor);
		g2d.drawString(title, 40, 22);
		g2d.setColor(textColor);
		g2d.drawString(title, 40, 21);

		/**
		 *  image
		 */
		g2d.drawImage(new ImageIcon("images/User28.png").getImage(), 10, 0,
				null, null);
	}

	/**
	 * This method sets the Actual Background Color of the Button.
	 *
	 * @param color the new start color
	 */
	public void setStartColor(Color color) {
		startColor = color;
	}

	/**
	 * This method sets the Pressed Color of the Button.
	 *
	 * @param pressedColor the new end color
	 */
	public void setEndColor(Color pressedColor) {
		endColor = pressedColor;
	}

	/**
	 * Gets the start color.
	 *
	 * @return  Starting Color of the Button
	 */
	public Color getStartColor() {
		return startColor;
	}

	/**
	 * Gets the end color.
	 *
	 * @return  Ending Color of the Button
	 */
	public Color getEndColor() {
		return endColor;
	}

	/**
	 * Gets the title.
	 *
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * Sets the title.
	 *
	 * @param title the new title
	 */
	public void setTitle(String title) {
		this.title = title;
	}
}

Commits for Aurocare_27_07_2018/AuroCareCommonUtil/src/main/java/com/bestray/healthcarecommonutil/util/UserInputsPanel.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 27 Jul, 2018 07:21:55 +0000