Skip to content
Permalink
Browse files

Change global font size with a slider and save the size in a file. After

restarting VennMaker, the saved font size will be used.
  • Loading branch information...
michael
michael committed Oct 17, 2018
1 parent 89b3722 commit 9da425d758b0c65b4a24ecdc07ac965a819b27c1
@@ -6,6 +6,7 @@
import files.IO;
import gui.AboutTeam;
import gui.ActorTableDialog;
import gui.ChangeFontSize;
import gui.ConfigRelationDialog;
import gui.EditDataProtection;
import gui.EditMetaInformationDialog;
@@ -203,6 +204,12 @@ public void action(MenuEvent e)
{
VennMakerActions.aboutUpdate();
}


if ("changefontsize".equals(e.getInfo().getMessage()))
{
new ChangeFontSize();
}

if ("aboutteam".equals(e.getInfo().getMessage()))
{
@@ -16,6 +16,7 @@
import gui.SelectInterviewDialog;
import gui.TestVersion;
import gui.VennMaker;
import gui.utilities.VennMakerUIConfig;
import interview.InterviewController;
import interview.InterviewLayer;

@@ -55,6 +55,7 @@
import events.RenameActorEvent;
import events.SetAttributeEvent;
import files.FileOperations;
import gui.utilities.VennMakerUIConfig;

/**
*
@@ -296,6 +297,10 @@ public void mouseClicked(MouseEvent e)

attributeValueTable.addMouseListener(new AttributeMouseListener(1,
attributeValueTable.getColumnCount() - 1));

actorNamesTable.setRowHeight((int) (VennMakerUIConfig.getFontSize()+15));
attributeValueTable.setRowHeight((int) (VennMakerUIConfig.getFontSize()+15));


actorNamesTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener()
@@ -606,8 +611,6 @@ public void ordered(boolean ordered)
* for the real table models (ActorsNameTableModel &
* AttributeValueTableModel)
*
*
*
*/
abstract class ActorDataBaseModel extends DefaultTableModel
{
@@ -710,8 +713,8 @@ public boolean isCellEditable(int row, int col)
}

/**
* Editor f�r editierbare Zellen in der ActorTable, um zus�tzliche
* funktionalit�t zu implementieren.
* Editor fuer editierbare Zellen in der ActorTable, um zusuetzliche
* funktionalitaet zu implementieren.
*/
class ActorTableCellEditor extends DefaultCellEditor
{
@@ -745,6 +748,7 @@ public Component getTableCellEditorComponent(JTable table, Object value,

}
}

return editorComponent;
// return super.getTableCellEditorComponent(table, value, isSelected,
// row, column);
@@ -44,6 +44,7 @@
import events.ComplexEvent;
import events.NewActorEvent;
import events.RemoveRelationEvent;
import gui.utilities.VennMakerUIConfig;

/**
*
@@ -248,6 +249,8 @@ private void build()
relationTable.getSelectionModel().setSelectionMode(
ListSelectionModel.SINGLE_SELECTION);

relationTable.setRowHeight((int) (VennMakerUIConfig.getFontSize()+15));

relationTable.addMouseListener(new AttributeMouseListener(
INDEX_RELATION_GROUP, INDEX_RELATION_GROUP));

@@ -551,6 +551,14 @@ public JMenuBar createVennMakerMenu() throws FileNotFoundException
aboutUpdate.setActionCommand("aboutupdate");
aboutUpdate.addActionListener(this);
menu.add(aboutUpdate);

// -------Change font size --------
JMenuItem changeFontSize = new JMenuItem(
Messages.getString("VennMaker.Change_FontSize")); //$NON-NLS-1$

changeFontSize.setActionCommand("changefontsize");
changeFontSize.addActionListener(this);
menu.add(changeFontSize);

// -------Team info --------
icon = SvgBatikResizableIcon
@@ -37,6 +37,7 @@
import events.ActorInNetworkEvent;
import events.VennMakerEvent;
import export.ExportCSV;
import gui.utilities.VennMakerUIConfig;

/**
* Dialog to show Statistics about the actors
@@ -438,6 +439,7 @@ else if (x > 0)
new String[] {
Messages.getString("ViewStatisticDialog.6"), Messages.getString("ViewStatisticDialog.7") }); //$NON-NLS-1$ //$NON-NLS-2$
myTable.setModel(dtm);
myTable.setRowHeight((int) (VennMakerUIConfig.getFontSize()+15));
dtm.fireTableDataChanged();
dtm.fireTableStructureChanged();

@@ -0,0 +1,66 @@
package gui.utilities;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class VennMakerUIConfig {

private static float fontSize = 0.0f;

/**
* Get global font size.
* @return
*/
public static float getFontSize() {

if (fontSize == 0.0f)
{
fontSize = 12.0f;
BufferedReader brTest;
try {
brTest = new BufferedReader(new FileReader("vennmakerfontsize.txt"));

try {
fontSize = new Float(brTest.readLine());
} catch (NumberFormatException e) {
} catch (IOException e) {
}
} catch (FileNotFoundException e1) {
System.out.println("vennmakerfontsize.txt not found");

}

System.out.println("Firstline is : " + fontSize);
}
return fontSize;
}

/**
* Set the global font size
* @param float size
* @return
*/
public static boolean setFontSize(float size) {

PrintWriter writer;
try {
writer = new PrintWriter("vennmakerfontsize.txt", "UTF-8");
writer.println(size);
writer.close();

} catch (FileNotFoundException e) {
return false;
} catch (UnsupportedEncodingException e) {
return false;
}
fontSize = size;
return true;
}
}

0 comments on commit 9da425d

Please sign in to comment.
You can’t perform that action at this time.