1 package org.woehlke.computer.kurzweil.simulated.evolution.view.widgets;
2
3 import lombok.Getter;
4 import lombok.ToString;
5 import org.woehlke.computer.kurzweil.simulated.evolution.config.ComputerKurzweilProperties;
6 import org.woehlke.computer.kurzweil.simulated.evolution.view.layouts.FlowLayoutCenter;
7
8 import javax.swing.*;
9 import javax.swing.border.CompoundBorder;
10 import java.awt.event.KeyEvent;
11 import java.io.Serializable;
12
13
14
15
16
17
18
19
20
21 @Getter
22 @ToString
23 public abstract class SubTabImpl extends JPanel implements Serializable {
24
25 private static final long serialVersionUID = 242L;
26
27 private final String title;
28 private final String subTitle;
29 private final String toolTipText;
30 private final Icon icon;
31 private final int keyEvent;
32 private final ComputerKurzweilProperties properties;
33 private final CompoundBorder border;
34 private final FlowLayoutCenter layout;
35
36 public SubTabImpl(
37 String title,
38 String subTitle,
39 String toolTipText,
40 Icon icon,
41 int keyEvent,
42 ComputerKurzweilProperties properties
43 ) {
44 this.title = title;
45 this.subTitle = subTitle;
46 this.toolTipText = toolTipText;
47 this.icon = icon;
48 this.keyEvent = keyEvent;
49 this.properties = properties;
50 this.border = getDoubleBorder();
51 this.setBorder( this.border);
52 this.layout = new FlowLayoutCenter();
53 this.setLayout( this.layout);
54 }
55
56 public SubTabImpl(String title, ComputerKurzweilProperties properties) {
57 this.title = title;
58 this.subTitle = title;
59 this.toolTipText = title;
60 this.icon = null;
61 this.keyEvent = KeyEvent.CHAR_UNDEFINED;
62 this.properties = properties;
63 this.border = getDoubleBorder();
64 this.setBorder( this.border);
65 this.layout = new FlowLayoutCenter();
66 this.setLayout( this.layout);
67 }
68
69 private CompoundBorder getDoubleBorder(){
70 int left = this.getProperties().getAllinone().getView().getBorderPaddingX();
71 int right = this.getProperties().getAllinone().getView().getBorderPaddingX();
72 int top = this.getProperties().getAllinone().getView().getBorderPaddingY();
73 int bottom = this.getProperties().getAllinone().getView().getBorderPaddingY();
74 return BorderFactory.createCompoundBorder(
75 BorderFactory.createEmptyBorder(left,right,top,bottom),
76 BorderFactory.createEmptyBorder(left,right,top,bottom)
77 );
78 }
79
80 }