Skip to content

Commit

Permalink
Completes and closes #866
Browse files Browse the repository at this point in the history
  • Loading branch information
Draque Thompson committed Mar 18, 2020
1 parent 9374ce5 commit 0d4f834
Show file tree
Hide file tree
Showing 19 changed files with 492 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ public void characters(char[] ch, int start, int length)
} else if (blangRegexFontOvr) {
propertiesManager.setOverrideRegexFont(new String(ch, start, length).equals(PGTUtil.TRUE));
} else if (bfontSize) {
propertiesManager.setFontSize(Integer.parseInt(new String(ch, start, length)));
propertiesManager.setFontSize(Double.valueOf(new String(ch, start, length)));
bfontSize = false;
} else if (bfontStyle) {
propertiesManager.setFontStyle(Integer.parseInt(new String(ch, start, length)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2019, Draque Thompson, [email protected]
* Copyright (c) 2014-2020, Draque Thompson, [email protected]
* All rights reserved.
*
* Licensed under: MIT Licence
Expand Down Expand Up @@ -55,8 +55,7 @@ public final class PCellEditor extends AbstractCellEditor implements TableCellEd
public PCellEditor(boolean _useConFont, DictCore _core) {
core = _core;
useConFont = _useConFont;
Integer preSize = core.getPropertiesManager().getFontSize();
preSize = preSize == null ? 0 : preSize;
double preSize = core.getPropertiesManager().getFontSize();

Font defFont = useConFont ? core.getPropertiesManager().getFontCon()
: core.getPropertiesManager().getFontLocal();
Expand Down Expand Up @@ -227,7 +226,7 @@ public void mouseReleased(MouseEvent e) {
}

/**
* @param ignoreListenerSilencing the ignoreListenerSilencing to set
* @param _ignoreListenerSilencing the ignoreListenerSilencing to set
*/
public void setIgnoreListenerSilencing(boolean _ignoreListenerSilencing) {
this.ignoreListenerSilencing = _ignoreListenerSilencing;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2019, Draque Thompson, [email protected]
* Copyright (c) 2014-2020, Draque Thompson, [email protected]
* All rights reserved.
*
* Licensed under: MIT Licence
Expand Down Expand Up @@ -49,8 +49,7 @@ public class PCellRenderer implements TableCellRenderer {
public PCellRenderer(boolean _useConFont, DictCore _core) {
core = _core;
useConFont = _useConFont;
Integer preSize = core.getPropertiesManager().getFontSize();
preSize = preSize == null ? 0 : preSize;
double preSize = core.getPropertiesManager().getFontSize();

Font selectedFont = useConFont ?
core.getPropertiesManager().getFontCon() :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void setupRightClickMenu() {
insertImage.addActionListener((ActionEvent ae) -> {
try {
ImageNode image = core.getImageCollection()
.openNewImage((Window) parentPane.getTopLevelAncestor());
.openNewImage((Window) parentPane.getTopLevelAncestor(), core.getWorkingDirectory());
if (image != null) {
// null node means user cancelled process
addImage(image);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
*/
public class PTextFieldFilter extends DocumentFilter {

private final Window parent;

public PTextFieldFilter(Window _parent) {
parent = _parent;
public PTextFieldFilter() {
}

@Override
Expand All @@ -49,8 +46,6 @@ public void insertString(FilterBypass fb, int offset, String insert,

if (test(sb.toString())) {
super.insertString(fb, offset, insert, attr);
} else {
InfoBox.warning("Numbers Only", "This field allows only numeric values.", parent);
}
}

Expand Down Expand Up @@ -82,8 +77,6 @@ public void replace(FilterBypass fb, int offset, int length, String text,

if (test(sb.toString())) {
super.replace(fb, offset, length, text, attrs);
} else {
InfoBox.warning("Numbers Only", "This field allows only numeric values.", parent);
}

}
Expand All @@ -98,8 +91,6 @@ public void remove(FilterBypass fb, int offset, int length)

if (test(sb.toString())) {
super.remove(fb, offset, length);
} else {
InfoBox.warning("Numbers Only", "This field allows only numeric values.", parent);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2019, Draque Thompson
* Copyright (c) 2016-2020, Draque Thompson, [email protected]
* All rights reserved.
*
* Licensed under: MIT Licence
Expand Down Expand Up @@ -201,7 +201,7 @@ private void setupRightClickMenu() {
insertImage.addActionListener((ActionEvent ae) -> {
try {
ImageNode image = core.getImageCollection()
.openNewImage((Window)parentPane.getTopLevelAncestor());
.openNewImage((Window)parentPane.getTopLevelAncestor(), core.getWorkingDirectory());
if (image != null) {
// null node means user cancelled process
addImage(image);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/darisadesigns/polyglotlina/DictCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.awt.Desktop;
import org.darisadesigns.polyglotlina.CustomControls.InfoBox;
import org.darisadesigns.polyglotlina.CustomControls.PAlphaMap;
import org.darisadesigns.polyglotlina.CustomControls.PFrame;
import org.darisadesigns.polyglotlina.ManagersCollections.PropertiesManager;
import org.darisadesigns.polyglotlina.ManagersCollections.GrammarManager;
import org.darisadesigns.polyglotlina.ManagersCollections.PronunciationMgr;
Expand Down Expand Up @@ -273,7 +272,7 @@ public void pushUpdateWithCore(DictCore _core) {
*
* @return
*/
public PFrame getRootWindow() {
public ScrMainMenu getRootWindow() {
return rootWindow;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/darisadesigns/polyglotlina/IOHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,18 @@ public static CustHandler getHandlerFromByteArray(byte[] byteArray, DictCore _co
* cancels.
*
* @param parent parent window of operation
* @param workingDirectory
* @return buffered image selected by user
* @throws IOException on file read error
*/
public static BufferedImage openImage(Window parent) throws IOException {
public static BufferedImage openImage(Window parent, File workingDirectory) throws IOException {
BufferedImage ret = null;
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Select Image");
FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "jpg", "jpeg", "tiff", "bmp", "png");
chooser.setFileFilter(filter);
String fileName;
chooser.setCurrentDirectory(new File("."));
chooser.setCurrentDirectory(workingDirectory);

if (chooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
fileName = chooser.getSelectedFile().getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.darisadesigns.polyglotlina.PGTUtil;
import java.awt.Window;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

Expand Down Expand Up @@ -54,13 +55,14 @@ public ImageNode[] getAllImages() {
* Pulls in new image from user selected file
* Returns null if user cancels process
* @param parent parent form
* @param workingDirectory
* @return ImageNode inserted into collection with populated image
* @throws IOException on file read error
*/
public ImageNode openNewImage(Window parent) throws Exception {
public ImageNode openNewImage(Window parent, File workingDirectory) throws Exception {
ImageNode image = null;
try {
BufferedImage buffImg = IOHandler.openImage(parent);
BufferedImage buffImg = IOHandler.openImage(parent, workingDirectory);

if (buffImg != null) {
image = new ImageNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public class PropertiesManager {
private Font conFont = null;
private Integer conFontStyle = Font.PLAIN;
private Integer conFontSize = 12;
private double conFontSize = 12;
private double localFontSize = 12;
private final PAlphaMap<String, Integer> alphaOrder;
private String alphaPlainText = "";
Expand Down Expand Up @@ -216,7 +216,8 @@ public byte[] getCachedLocalFont() {
}

public void setFontFromFile(String fontPath) throws IOException, FontFormatException {
setFontCon(PFontHandler.getFontFromFile(fontPath).deriveFont(conFontStyle, conFontSize), conFontStyle, conFontSize);
setFontCon(PFontHandler.getFontFromFile(fontPath)
.deriveFont(conFontStyle, (float)conFontSize), conFontStyle, (float)conFontSize);
cachedConFont = IOHandler.getFileByteArray(fontPath);
}

Expand Down Expand Up @@ -284,7 +285,7 @@ public boolean syncCachedFontCon() throws Exception {
* @param _fontStyle The style of the font (bold, underlined, etc.)
* @param _fontSize Size of font
*/
public void setFontCon(Font _fontCon, Integer _fontStyle, Integer _fontSize) {
public void setFontCon(Font _fontCon, Integer _fontStyle, double _fontSize) {
setFontConRaw(_fontCon);
setFontSize(_fontSize);
setFontStyle(_fontStyle);
Expand Down Expand Up @@ -330,7 +331,7 @@ public Font getFontCon() {

return retFont == null ?
PGTUtil.CHARIS_UNICODE.deriveFont((float)core.getOptionsManager().getMenuFontSize()) :
retFont.deriveFont(conFontStyle, conFontSize);
retFont.deriveFont(conFontStyle, (float)conFontSize);
}

/**
Expand Down Expand Up @@ -361,13 +362,13 @@ public Integer getFontStyle() {
*/
public void setFontStyle(Integer _fontStyle) {
conFontStyle = _fontStyle;
conFont = conFont.deriveFont(conFontStyle, conFontSize);
conFont = conFont.deriveFont(conFontStyle, (float)conFontSize);
}

/**
* @return the fontSize
*/
public Integer getFontSize() {
public double getFontSize() {
return conFontSize;
}

Expand All @@ -376,11 +377,9 @@ public Integer getFontSize() {
*
* @param _fontSize the fontSize to set
*/
public void setFontSize(Integer _fontSize) {
if (_fontSize != null) {
conFontSize = _fontSize < 0 ? 12 : _fontSize;
conFont = conFont.deriveFont(conFontStyle, conFontSize);
}
public void setFontSize(double _fontSize) {
conFontSize = _fontSize < 0 ? 12 : _fontSize;
conFont = conFont.deriveFont(conFontStyle, (float)conFontSize);
}

/**
Expand Down Expand Up @@ -571,7 +570,7 @@ public void writeXML(Document doc, Element rootElement) {

// store font size
wordValue = doc.createElement(PGTUtil.LANG_PROP_FONT_SIZE_XID);
wordValue.appendChild(doc.createTextNode(conFontSize.toString()));
wordValue.appendChild(doc.createTextNode(Double.toString(conFontSize)));
propContainer.appendChild(wordValue);

// store font size for local language font
Expand Down Expand Up @@ -800,7 +799,7 @@ public void refreshFonts() throws Exception {

if (updatedConFont != null) {
conFont = PFontHandler.getFontFromFile(updatedConFont.getAbsolutePath());
conFont = conFont.deriveFont(conFontStyle, conFontSize);
conFont = conFont.deriveFont(conFontStyle, (float)conFontSize);
cachedConFont = IOHandler.getByteArrayFromFile(updatedConFont);
}

Expand Down Expand Up @@ -839,7 +838,7 @@ public boolean equals(Object comp) {
PropertiesManager prop = (PropertiesManager) comp;
ret = ((conFont == null) && (prop.conFont == null)) || conFont.equals(prop.conFont);
ret = ret && conFontStyle.equals(prop.conFontStyle);
ret = ret && conFontSize.equals(prop.conFontSize);
ret = ret && conFontSize == prop.conFontSize;
ret = ret && localFontSize == prop.localFontSize;
ret = ret && alphaPlainText.equals(prop.alphaPlainText);
ret = ret && langName.equals(prop.langName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public String getLeftYAxisLabel() {
}

/**
* @param leftYAxisLabel the leftYAxisLabel to set
* @param _leftYAxisLabel the leftYAxisLabel to set
*/
public void setLeftYAxisLabel(String _leftYAxisLabel) {
this.leftYAxisLabel = _leftYAxisLabel;
Expand All @@ -50,7 +50,7 @@ public String getRightYAxisLabel() {
}

/**
* @param rightYAxisLabel the rightYAxisLabel to set
* @param _rightYAxisLabel the rightYAxisLabel to set
*/
public void setRightYAxisLabel(String _rightYAxisLabel) {
this.rightYAxisLabel = _rightYAxisLabel;
Expand All @@ -75,7 +75,7 @@ public PGoogleBarChart(String _caption) {
* subsequent set should have 1 label and n - 1 values. It will not display
* otherwise.
*
* @param labels
* @param _labels
* @param values
*/
@Override
Expand Down Expand Up @@ -166,14 +166,14 @@ public String getDisplayHTML() {
}

/**
* @param labels the labels to set
* @param _labels the labels to set
*/
public void setLabels(String[] _labels) {
this.labels = _labels;
}

/**
* @param conFontName the conFontName to set
* @param _conFontName the conFontName to set
*/
public void setConFontName(String _conFontName) {
this.conFontName = _conFontName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static String buildWordReport(DictCore core, ScrProgressMenu progress) {
Map<String, Integer> phonemeCount = new HashMap<>();
Map<String, Integer> charCount = new HashMap<>();
Map<String, Integer> phonemeCombo2 = new HashMap<>();
ConWord wordList[] = core.getWordCollection().getWordNodes();
ConWord[] wordList = core.getWordCollection().getWordNodes();
String allChars = core.getPropertiesManager().getAlphaPlainText();
String alphabet = core.getPropertiesManager().getAlphaPlainText();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.commons.csv.CSVFormat;
import org.darisadesigns.polyglotlina.CustomControls.PRadioButton;
import org.darisadesigns.polyglotlina.ImportFileHelper.DuplicateOption;
import org.darisadesigns.polyglotlina.PGTUtil;

/**
*
Expand Down Expand Up @@ -426,7 +425,7 @@ public static ScrExcelImport run(DictCore _core, ScrMainMenu _parent) {

private void browseFile() {
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setCurrentDirectory(core.getWorkingDirectory());
FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel/CSV Documents", "xls", "xlsx", "xlsm", "csv", "txt", "tsv");
chooser.setFileFilter(filter);
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
Expand Down
Loading

0 comments on commit 0d4f834

Please sign in to comment.