Skip to content

Commit

Permalink
add view menu with global content (font) size scaling and allowing hi…
Browse files Browse the repository at this point in the history
…ding of project tree
  • Loading branch information
CarstenWickner committed Sep 11, 2015
1 parent 81a9fb8 commit eaf3d4e
Show file tree
Hide file tree
Showing 25 changed files with 369 additions and 107 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.hmx</groupId>
<artifactId>scitos</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>pom</packaging>
<name>scitos</name>
<description>parent project of SciToS</description>
Expand All @@ -17,7 +17,7 @@
</modules>

<properties>
<scitos.version>1.1.0</scitos.version>
<scitos.version>1.2.0</scitos.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
Expand Down
2 changes: 1 addition & 1 deletion scitos.ais/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.hmx</groupId>
<artifactId>scitos</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>scitos.ais</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion scitos.ais/scitos.ais.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.hmx</groupId>
<artifactId>scitos.ais</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>scitos.ais.core</artifactId>
<name>scitos.ais.core</name>
Expand Down
2 changes: 1 addition & 1 deletion scitos.ais/scitos.ais.domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.hmx</groupId>
<artifactId>scitos.ais</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>scitos.ais.domain</artifactId>
<build>
Expand Down
2 changes: 1 addition & 1 deletion scitos.ais/scitos.ais.view/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.hmx</groupId>
<artifactId>scitos.ais</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>scitos.ais.view</artifactId>
<name>scitos.ais.view</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,6 @@ public Component getTableCellRendererComponent(final JTable table, final Object
} else {
this.renderButton.setForeground(table.getForeground());
this.renderButton.setBackground(table.getSelectionBackground());
// this.renderButton.setBackground(UIManager.getLookAndFeelDefaults().getColor("Button.background"));
}
return this.renderButton;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.UndoableEditEvent;
import javax.swing.text.MutableAttributeSet;
Expand All @@ -40,6 +38,8 @@
import org.hmx.scitos.ais.domain.model.TextToken;
import org.hmx.scitos.core.i18n.Message;
import org.hmx.scitos.view.swing.IUndoManagedView;
import org.hmx.scitos.view.swing.components.ScaledLabel;
import org.hmx.scitos.view.swing.components.ScaledTextPane;

/**
* Part of the {@link InterviewView}, that is allowing to insert/modify the interview's text while no scoring (i.e. detail category assignments) has
Expand All @@ -52,7 +52,7 @@ public final class InterviewInputPanel extends JPanel implements IUndoManagedVie
/** The interview view this is a part of. */
private final InterviewView parentView;
/** The actual text pane to insert/modify the interview's text in. */
final JTextPane inputPane = new JTextPane();
final ScaledTextPane inputPane = new ScaledTextPane();

/**
* Main constructor.
Expand All @@ -64,10 +64,12 @@ public InterviewInputPanel(final InterviewView parentView) {
super(new GridBagLayout());
this.parentView = parentView;
// insert a hint label on the top of the input view
final JLabel hintLabel = new JLabel(Message.AIS_INTERVIEW_TEXTINPUT_HINT.get());
final ScaledLabel hintLabel = new ScaledLabel(Message.AIS_INTERVIEW_TEXTINPUT_HINT.get());
hintLabel.setToolTipText(Message.AIS_INTERVIEW_TEXTINPUT_HINT.get());
hintLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
final GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.BASELINE_LEADING;
constraints.weightx = 1;
this.add(hintLabel, constraints);
// insert the button for starting the actual scoring (i.e. replacing this input panel with the scoring panel)
final JButton button = new JButton(Message.AIS_INTERVIEW_START_SCORING.get());
Expand All @@ -82,6 +84,7 @@ public void actionPerformed(final ActionEvent event) {
}
});
constraints.anchor = GridBagConstraints.BASELINE_TRAILING;
constraints.weightx = 0;
constraints.gridx = 1;
this.add(button, constraints);
// make sure the input text pane is scrollable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.hmx.scitos.ais.view.swing.components;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
Expand Down Expand Up @@ -75,10 +76,10 @@ public InterviewPanel(final IProvider<Interview> displayedInterviewProvider, fin
@Override
public void updateUI() {
super.updateUI();
this.setBackground(UIManager.getLookAndFeelDefaults().getColor("TextPane.background"));
final Color background = UIManager.getColor("TextPane.background");
this.setBackground(background == null ? Color.WHITE : new Color(background.getRGB()));
}
};
this.viewPortView.setBackground(UIManager.getLookAndFeelDefaults().getColor("TextPane.background"));
this.addAncestorListener(new AncestorListener() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
Expand All @@ -49,6 +48,7 @@
import org.hmx.scitos.domain.IProvider;
import org.hmx.scitos.view.ScitosIcon;
import org.hmx.scitos.view.swing.ScitosClient;
import org.hmx.scitos.view.swing.components.ScaledLabel;

/**
* Tab view: representing a single participant, that has multiple interviews assigned.
Expand Down Expand Up @@ -84,7 +84,7 @@ public final class ParticipantInterviewGroupView extends AbstractAisProjectView<
public ParticipantInterviewGroupView(final ScitosClient client, final AisViewProject project, final String participantId,
final AisOption options) {
super(project, participantId, options, new BorderLayout());
final JLabel topicLabel = new JLabel(Message.AIS_INTERVIEW_CHANGE_ORDER.get());
final ScaledLabel topicLabel = new ScaledLabel(Message.AIS_INTERVIEW_CHANGE_ORDER.get());
topicLabel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
this.add(topicLabel, BorderLayout.NORTH);
this.contentArea = new JPanel(new GridBagLayout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.HierarchyEvent;
Expand All @@ -47,6 +48,7 @@
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableModel;
Expand All @@ -59,6 +61,7 @@
import org.hmx.scitos.core.i18n.Message;
import org.hmx.scitos.view.ScitosIcon;
import org.hmx.scitos.view.swing.MessageHandler;
import org.hmx.scitos.view.swing.ScitosApp;
import org.hmx.scitos.view.swing.ScitosClient;
import org.jopendocument.dom.OOXML;
import org.jopendocument.dom.XMLVersion;
Expand Down Expand Up @@ -158,7 +161,28 @@ void refresh() {
* @return scrollable table taking up the whole view
*/
private JScrollPane createTableFromModel(final TableModel tableModel) {
final JTable tableView = new JTable(tableModel);
final JTable tableView = new JTable(tableModel) {

@Override
public void updateUI() {
super.updateUI();
final float scaleFactor;
if (ScitosApp.getClient() == null) {
scaleFactor = 1f;
} else {
scaleFactor = ScitosApp.getClient().getContentScaleFactor();
}
final Font headerFont = UIManager.getFont("TableHeader.font");
if (headerFont != null) {
this.getTableHeader().setFont(new Font(headerFont.getAttributes()).deriveFont(headerFont.getSize2D() * scaleFactor));
}
final Font contentFont = UIManager.getFont("Table.font");
if (contentFont != null) {
this.setFont(new Font(contentFont.getAttributes()).deriveFont(contentFont.getSize2D() * scaleFactor));
this.setRowHeight(2 + Math.round(this.getFont().getSize2D() * scaleFactor));
}
}
};
tableView.setBorder(null);
tableView.setAutoCreateColumnsFromModel(true);
tableView.setAutoCreateRowSorter(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void actionPerformed(final ActionEvent event) {
this.add(addInterviewButton, BorderLayout.SOUTH);
this.refresh();
}

@Override
public void refresh() {
this.analysisPanel.refresh();
Expand Down
Loading

0 comments on commit eaf3d4e

Please sign in to comment.