1
16package org.tp23.antinstaller.renderer.swing;
17
18import java.awt.Dimension;
19import java.awt.Font;
20
21import javax.swing.JLabel;
22import javax.swing.JPanel;
23import javax.swing.text.JTextComponent;
24
25import org.tp23.antinstaller.input.CommentOutput;
26import org.tp23.antinstaller.input.OutputField;
27import org.tp23.gui.GBCF;
28
29public class CommentOutputRenderer
30 extends SwingOutputFieldRenderer {
31
32 protected AILabel fieldLabel = new AILabel();
33 protected JTextComponent explanatoryTextField;
35
36 private static Font boldCommentFont;
37 private static Font titleCommentFont;
38 static{
39 boldCommentFont = new JLabel().getFont(); try {
41 boldCommentFont = new Font(boldCommentFont.getFamily(), Font.BOLD, boldCommentFont.getSize());
42 titleCommentFont = new Font(boldCommentFont.getFamily(), Font.BOLD, 16);
43 }
44 catch (Exception ex) {
45 }
47 }
48
49 public CommentOutputRenderer() {
50 }
51
52 public void initComponent(JPanel parent){
53 try {
54 jbInit();
55 }
56 catch(Exception e) {
57 e.printStackTrace();
58 }
59 }
60
61 public void setOutputField(OutputField outputField) {
62 this.outputField = (CommentOutput)outputField; }
64 public void updateInputField(){
65 }
66
67 public JTextComponent getExplanatoryTextField() {
69 return explanatoryTextField;
70 }
71 public void setExplanatoryTextField(JTextComponent explanatoryTextField) {
73 this.explanatoryTextField = explanatoryTextField;
74 }
75
79 public void updateDefaultValue(){
80 fieldLabel.setText(outputField.getDisplayText());
81 if(explanatoryTextField != null) {
82 explanatoryTextField.setText(outputField.getExplanatoryText());
83 }
84 }
85 private void jbInit() throws Exception {
86
87 CommentOutput cOutputField = (CommentOutput)outputField;
89
90 fieldLabel.setText(cOutputField.getDisplayText());
91
92 if( OutputField.isTrue(cOutputField.getBold()) ){
93 fieldLabel.setFont(boldCommentFont);
94 }
95 if( OutputField.isTrue(cOutputField.getTitle()) ){
96 fieldLabel.setFont(titleCommentFont);
97 }
98 }
99 public int addSelf(JPanel content, GBCF cf, int row, boolean overflow) {
00 content.add(fieldLabel, cf.getSpan(row));
01 if(overflow){
02 fieldLabel.setOverflow(SizeConstants.OVERFLOW_TOTAL_SIZE);
03 } else {
04 fieldLabel.setOverflow(new Dimension(SizeConstants.FIELD_WIDTH + SizeConstants.LABEL_WIDTH, SizeConstants.FIELD_HEIGHT));
05 }
06 return ++row;
07 }
08
09
10
13 public void renderError() {
14 }
15}
16