Skip to content

Commit

Permalink
Puts an asterisk next to required fields
Browse files Browse the repository at this point in the history
This should close issue #40. This puts an asterisk next to required fields.  Adds a outputName method to MappableItem, Field, and Table.
  • Loading branch information
marc-outins committed May 6, 2015
1 parent 9a92f7f commit c51d121
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/org/ohdsi/rabbitInAHat/DetailsPanel.java
Expand Up @@ -143,8 +143,9 @@ public void showTable(Table table) {
DecimalFormat formatter = new DecimalFormat("#,###");
rowCountLabel.setText(formatter.format(table.getRowCount()));
fieldTable.clear();
for (Field field : table.getFields())
fieldTable.add(field.getName(), field.getType());
for (Field field : table.getFields()){
fieldTable.add(field.outputName(), field.getType());
}
commentsArea.setText(table.getComment());
}

Expand Down
16 changes: 8 additions & 8 deletions src/org/ohdsi/rabbitInAHat/LabeledRectangle.java
Expand Up @@ -100,24 +100,24 @@ public void paint(Graphics g) {
g2d.setFont(new Font("default", Font.PLAIN, FONT_SIZE));
FontMetrics fm = g2d.getFontMetrics();

Rectangle2D r = fm.getStringBounds(item.getName(), g2d);
Rectangle2D r = fm.getStringBounds(item.outputName(), g2d);
if (r.getWidth() >= width) {
int breakPoint = 0;
int index = nextBreakPoint(item.getName(), 0);
double midPoint = item.getName().length() / 2d;
int index = nextBreakPoint(item.outputName(), 0);
double midPoint = item.outputName().length() / 2d;
while (index != -1) {
if (Math.abs(index - midPoint) < Math.abs(breakPoint - midPoint))
breakPoint = index;
index = nextBreakPoint(item.getName(), index + 1);
index = nextBreakPoint(item.outputName(), index + 1);
}
if (breakPoint == 0) {
int textX = (this.getWidth() - (int) r.getWidth()) / 2;
int textY = (this.getHeight() - (int) r.getHeight()) / 2 + fm.getAscent();
g2d.drawString(item.getName(), x + textX, y + textY);
g2d.drawString(item.outputName(), x + textX, y + textY);
}
breakPoint++;
String line1 = item.getName().substring(0, breakPoint);
String line2 = item.getName().substring(breakPoint);
String line1 = item.outputName().substring(0, breakPoint);
String line2 = item.outputName().substring(breakPoint);
r = fm.getStringBounds(line1, g2d);
int textX = (this.getWidth() - (int) r.getWidth()) / 2;
int textY = (this.getHeight() / 2 - (int) r.getHeight()) / 2 + fm.getAscent();
Expand All @@ -129,7 +129,7 @@ public void paint(Graphics g) {
} else {
int textX = (this.getWidth() - (int) r.getWidth()) / 2;
int textY = (this.getHeight() - (int) r.getHeight()) / 2 + fm.getAscent();
g2d.drawString(item.getName(), x + textX, y + textY);
g2d.drawString(item.outputName(), x + textX, y + textY);
}
}

Expand Down
10 changes: 9 additions & 1 deletion src/org/ohdsi/rabbitInAHat/dataModel/Field.java
Expand Up @@ -44,7 +44,15 @@ public void setTable(Table table) {
public String getName() {
return name;
}


public String outputName(){
if(!isNullable){
return "*" + name;
}else{
return name;
}
}

public void setName(String name) {
this.name = name;
}
Expand Down
1 change: 1 addition & 0 deletions src/org/ohdsi/rabbitInAHat/dataModel/MappableItem.java
Expand Up @@ -20,5 +20,6 @@
import java.io.Serializable;

public interface MappableItem extends Serializable{
public String outputName();
public String getName();
}
3 changes: 3 additions & 0 deletions src/org/ohdsi/rabbitInAHat/dataModel/Table.java
Expand Up @@ -41,6 +41,9 @@ public String getName() {
return name;
}

public String outputName(){
return getName();
}
public void setName(String name) {
this.name = name;
}
Expand Down

0 comments on commit c51d121

Please sign in to comment.