forked from ghajba/dropbox-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD.java
More file actions
104 lines (84 loc) · 3.61 KB
/
Copy pathD.java
File metadata and controls
104 lines (84 loc) · 3.61 KB
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
import java.awt.Dimension;
//NUMERO AUREO?
import java.awt.Font;
import java.awt.Toolkit;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
public class D {
static double height, width;
static int XResolution, YResolution, SAMPLE_NUMBER=7;
public static Dimension screen()
{
return new Dimension((int)Toolkit.getDefaultToolkit().getScreenSize().getWidth(),(int)Toolkit.getDefaultToolkit().getScreenSize().getHeight());
}
public static void SetGrid(Dimension d, int resx, int resy)
{
width=d.getWidth(); height=d.getHeight();
XResolution = resx; YResolution = resy;
}
public static int GetXbyGrid(int resx)
{
return (int) (width/XResolution*resx);
}
public static int GetYbyGrid(int resy)
{
return (int) (height/YResolution*resy);
}
public static int GetLenghtXbyPercent(double percentage)
{
return (int) (width/100*percentage);
}
public static int GetHeightYbyPercent(double percentage)
{
return (int) (height/100*percentage);
}
public static int GetFontSizebyPercent(double percent)
{
return (int) (height/100*percent);
}
public static void SetGivenSquaresFixedBounds(JComponent component, int resx, int resy, int lenghtx, int lenghty)
{
component.setBounds(GetXbyGrid(resx), GetYbyGrid(resy), GetXbyGrid(resx+lenghtx)-GetXbyGrid(resx), GetYbyGrid(resy+lenghty)-GetYbyGrid(resy));
}
public static void SetGivenLenghtFixedBoundsPro(JComponent component, int resx, int resy, double percentage, int style)
{
component.setFont(new Font("Tahoma", style, SAMPLE_NUMBER));
component.setBounds(resx, resy, component.getPreferredSize().width, component.getPreferredSize().height);
double coefficent=(double)component.getWidth()/(double)SAMPLE_NUMBER;
int font=(int) (GetLenghtXbyPercent(percentage)/coefficent);
component.setFont(new Font("Tahoma", style, font));
component.setBounds(resx,resy,component.getPreferredSize().width, component.getPreferredSize().height);
}
public static void SetGivenHeightFixedBoundsPro(JComponent component, int resx, int resy, double percentage, int style)
{
component.setFont(new Font("Tahoma", style, SAMPLE_NUMBER));
component.setBounds(resx, resy, component.getPreferredSize().width, component.getPreferredSize().height);
double coefficent=(double)component.getHeight()/(double)SAMPLE_NUMBER;
int font=(int) (GetHeightYbyPercent(percentage)/coefficent);
component.setFont(new Font("Tahoma", style, font));
component.setBounds(resx,resy,component.getPreferredSize().width, component.getPreferredSize().height);
}
public static void AdjustLenghtBounds(JComponent component, double percent)
{
component.setBounds(component.getX(),component.getY(),GetLenghtXbyPercent(percent),component.getSize().height);
}
public static void AdjustHeightBounds(JComponent component, double percent)
{
component.setBounds(component.getX(),component.getY(),component.getSize().width,GetHeightYbyPercent(percent));
}
public static void CenterJLabelText(JComponent component, JLabel label)
{
label.setHorizontalAlignment(SwingConstants.CENTER);
}
public static void SetFontbyHeight(JComponent component, int style)
{
int save1 = component.getHeight(), save2 = component.getWidth();
component.setFont(new Font("Tahoma", style, SAMPLE_NUMBER));
component.setBounds(component.getX(), component.getY(), component.getPreferredSize().width, component.getPreferredSize().height);
double coefficent=(double)component.getHeight()/(double)SAMPLE_NUMBER;
int font=(int) (save1/coefficent);
component.setFont(new Font("Tahoma", style, font));
component.setBounds(component.getX(),component.getY(),save2, save1);
}
}