Merge branch 'master_13.5.1' into omaha_13.5.1
Former-commit-id: 64b7a7f6a035d5832f2338d854780b16d22306db
This commit is contained in:
commit
97ef150656
27 changed files with 1170 additions and 777 deletions
|
@ -8,11 +8,11 @@
|
|||
Modify:
|
||||
|
||||
06/14/2013 Xiaochuan DR 15733 Initial creation
|
||||
|
||||
-->
|
||||
07/25/2013 Greg Hull DR 15733 Deleted. moved to TextEditorCfg.xml
|
||||
-->
|
||||
|
||||
<fontSizeCfg>
|
||||
<SizeButtonCfg>
|
||||
<!--<fontSizeCfg>
|
||||
<SizeButt
|
||||
<LabelName>Small Font</LabelName>
|
||||
<SizeEnabled>true</SizeEnabled>
|
||||
<FontSize>9</FontSize>
|
||||
|
@ -22,12 +22,12 @@
|
|||
<LabelName>Medium Font</LabelName>
|
||||
<SizeEnabled>true</SizeEnabled>
|
||||
<FontSize>11</FontSize>
|
||||
<Selected>false</Selected>
|
||||
<Selected>true</Selected>
|
||||
</SizeButtonCfg>
|
||||
<SizeButtonCfg>
|
||||
<LabelName>Large Font</LabelName>
|
||||
<SizeEnabled>true</SizeEnabled>
|
||||
<FontSize>13</FontSize>
|
||||
<Selected>true</Selected>
|
||||
<Selected>false</Selected>
|
||||
</SizeButtonCfg>
|
||||
</fontSizeCfg>
|
||||
</fontSizeCfg>-->
|
|
@ -10,14 +10,12 @@
|
|||
|
||||
Modify:
|
||||
|
||||
06/14/2013 Xiaochuan DR 15733 Initial creation
|
||||
07/18/2013 B. Hebbard per G. Hull DR 15733 Update highlightBG & FG
|
||||
|
||||
-->
|
||||
|
||||
<textColorsCfg>
|
||||
06/14/2013 Xiaochuan DR 15733 Initial creation
|
||||
07/25/2013 Greg Hull DR 15733 Deleted. moved to TextEditorCfg.xml
|
||||
-->
|
||||
<!--<textColorsCfg
|
||||
<TextColorElement paramName="textBG" color="255, 255, 255"/>
|
||||
<TextColorElement paramName="textFG" color="0, 0,0"/>
|
||||
<TextColorElement paramName="textFG" color="BLACK"/>
|
||||
<TextColorElement paramName="highlightBG" color="85, 152, 215"/>
|
||||
<TextColorElement paramName="highlightFG" color="255, 255, 255"/>
|
||||
</textColorsCfg>
|
||||
<TextColorElement paramName="highlightFG" color="PINK"/>
|
||||
</textColorsCfg> -->
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!--
|
||||
The file is used to set user preferences for the TextEditor.
|
||||
|
||||
|
||||
History:
|
||||
|
||||
07/25/2013 Greg Hull DR 15733 Created (and modified) from FontSizeCfg.xml and TextColorsCfg.xlm
|
||||
|
||||
-->
|
||||
<textEditorCfg>
|
||||
|
||||
<defaultNumEditors>4</defaultNumEditors>
|
||||
|
||||
<maxNumEditors>8</maxNumEditors>
|
||||
|
||||
<!-- The format can be either the name of a color or RGB values
|
||||
-->
|
||||
<textForegroundColor>BLACK</textForegroundColor>
|
||||
<textBackgroundColor>WHITE</textBackgroundColor>
|
||||
<highlightTextForegroundColor>0, 0, 0</highlightTextForegroundColor>
|
||||
<highlightTextBackgroundColor>85, 152, 215</highlightTextBackgroundColor>
|
||||
|
||||
<!-- The fonts available under the Options menu. Only one should be selected -->
|
||||
<fontSizeCfg>
|
||||
<SizeButtonCfg>
|
||||
<LabelName>Small</LabelName>
|
||||
<FontSize>9</FontSize>
|
||||
<Selected>false</Selected>
|
||||
</SizeButtonCfg>
|
||||
<SizeButtonCfg>
|
||||
<LabelName>Medium</LabelName>
|
||||
<FontSize>11</FontSize>
|
||||
<Selected>true</Selected>
|
||||
</SizeButtonCfg>
|
||||
<SizeButtonCfg>
|
||||
<LabelName>Large</LabelName>
|
||||
<FontSize>13</FontSize>
|
||||
<Selected>false</Selected>
|
||||
</SizeButtonCfg>
|
||||
<!-- Can add more buttons/fonts like this .....
|
||||
<SizeButtonCfg>
|
||||
<LabelName>Giant</LabelName>
|
||||
<FontSize>20</FontSize>
|
||||
<FontName>Helvetica</FontName>
|
||||
<Selected>false</Selected>
|
||||
</SizeButtonCfg>
|
||||
-->
|
||||
</fontSizeCfg>
|
||||
|
||||
</textEditorCfg>
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.viz.texteditor.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
|
@ -38,7 +39,8 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 07, 2013 DR 15733 Xiaochuan Initial creation
|
||||
* Jun 07, 2013 DR 15733 Xiaochuan Initial creation
|
||||
* Jul 25, 2013 DR 15733 Greg Hull Now part of TextEditorCfg ; don't return null array
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,7 +54,7 @@ public class FontSizeCfg implements ISerializableObject {
|
|||
private List<SizeButtonCfg> buttons;
|
||||
|
||||
public List<SizeButtonCfg> getButtons() {
|
||||
return buttons;
|
||||
return ( buttons != null ? buttons : new ArrayList<SizeButtonCfg>() );
|
||||
}
|
||||
|
||||
public void setButtons(List<SizeButtonCfg> buttons) {
|
||||
|
|
|
@ -57,8 +57,6 @@ public class RGBColorAdapter extends XmlAdapter<String, RGB> {
|
|||
|
||||
int sz = colorString.split(",").length;
|
||||
if( colorString.split(",").length == 1) {
|
||||
System.out.println(" Convert string color "
|
||||
+ colorString + ",,,");
|
||||
rgb = RGBColors.getRGBColor(colorString);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 07, 2013 DR 15733 Xiaochuan Initial creation
|
||||
* July 25, 2013 DR 15733 G. Hull now part of TextEditorCfg ; rm sizeEnabled
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -25,17 +26,20 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
|
|||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class SizeButtonCfg implements ISerializableObject {
|
||||
|
||||
private final int DEFAULT_FONT_SIZE = 11;
|
||||
|
||||
@XmlElement(name = "LabelName")
|
||||
private String labelName;
|
||||
private String labelName="Medium";
|
||||
|
||||
@XmlElement(name = "SizeEnabled")
|
||||
private boolean sizeEnabled;
|
||||
|
||||
@XmlElement(name = "FontSize")
|
||||
private int fontSize;
|
||||
@XmlElement(name = "FontName")
|
||||
private String fontName = "Courier";
|
||||
|
||||
@XmlElement(name = "FontSize")
|
||||
private int fontSize= DEFAULT_FONT_SIZE;
|
||||
|
||||
@XmlElement(name = "Selected")
|
||||
private boolean selected;
|
||||
private boolean selected=true;
|
||||
|
||||
public String getLabelName() {
|
||||
return labelName;
|
||||
|
@ -45,20 +49,15 @@ public class SizeButtonCfg implements ISerializableObject {
|
|||
this.labelName = labelName;
|
||||
}
|
||||
|
||||
public boolean isSizeEnabled() {
|
||||
return sizeEnabled;
|
||||
}
|
||||
|
||||
public void setSizeEnabled(boolean sizeEnabled) {
|
||||
this.sizeEnabled = sizeEnabled;
|
||||
}
|
||||
|
||||
public int getFontSize() {
|
||||
return fontSize;
|
||||
if( fontSize < 5 || fontSize > 40 ) { // sanity check
|
||||
return DEFAULT_FONT_SIZE;
|
||||
}
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
public void setFontSize(int fontSize) {
|
||||
this.fontSize = fontSize;
|
||||
this.fontSize = fontSize;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
|
@ -68,4 +67,12 @@ public class SizeButtonCfg implements ISerializableObject {
|
|||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public String getFontName() {
|
||||
return fontName;
|
||||
}
|
||||
|
||||
public void setFontName(String fontName) {
|
||||
this.fontName = fontName;
|
||||
}
|
||||
}
|
|
@ -1,18 +1,7 @@
|
|||
package com.raytheon.viz.texteditor.dialogs;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* OBSOLETE - Class removed
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -21,6 +10,7 @@ import org.eclipse.swt.graphics.RGB;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 24, 2013 DR 15733 Xiaochuan Initial creation
|
||||
* Jul 29, 2013 DR 15733 B. Hebbard Mark class deleted (per G. Hull)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -28,31 +18,6 @@ import org.eclipse.swt.graphics.RGB;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "TextColorElement")
|
||||
public class TextColorElement implements ISerializableObject {
|
||||
|
||||
@XmlAttribute
|
||||
@XmlJavaTypeAdapter(RGBColorAdapter.class)
|
||||
private RGB color;
|
||||
|
||||
@XmlAttribute
|
||||
private String paramName;
|
||||
|
||||
public RGB getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(RGB color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getParamName() {
|
||||
return paramName;
|
||||
}
|
||||
|
||||
public void setParamName(String paramName) {
|
||||
this.paramName = paramName;
|
||||
}
|
||||
|
||||
public class TextColorElement {
|
||||
// OBSOLETE - Class removed as part of refactor by G. Hull for DR 15733
|
||||
}
|
|
@ -1,36 +1,7 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.texteditor.dialogs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* OBSOLETE - Class removed
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -39,28 +10,13 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 15, 2013 DR 15733 Xiaochuan Initial creation
|
||||
* Jul 29, 2013 DR 15733 B. Hebbard Mark class deleted (per G. Hull)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author XHuang
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement(name = "textColorsCfg")
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class TextColorsCfg implements ISerializableObject {
|
||||
@XmlElements({ @XmlElement(name = "TextColorElement", type = TextColorElement.class) })
|
||||
private List<TextColorElement> colorElements;
|
||||
|
||||
public List<TextColorElement> getTextColorElements() {
|
||||
return colorElements;
|
||||
}
|
||||
|
||||
public void setTextColorElements(List<TextColorElement> colorElements) {
|
||||
this.colorElements = colorElements;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class TextColorsCfg {
|
||||
// OBSOLETE - Class removed as part of refactor by G. Hull for DR 15733
|
||||
}
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.texteditor.dialogs;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 15, 2013 DR 15733 Xiaochuan Initial creation
|
||||
* Jul 25, 2013 DR 15733 Greg Hull Combined FontSizeCfg, elements from TextColorsCfg
|
||||
* and added defaultNumEditors and maxNumEditors
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author XHuang
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement(name = "textEditorCfg")
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class TextEditorCfg implements ISerializableObject {
|
||||
|
||||
@XmlElement
|
||||
private Integer defaultNumEditors=4;
|
||||
|
||||
@XmlElement
|
||||
private Integer maxNumEditors=8;
|
||||
|
||||
@XmlElement
|
||||
private FontSizeCfg fontSizeCfg=new FontSizeCfg();
|
||||
|
||||
private static SizeButtonCfg selectedFontButton = null;
|
||||
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(RGBColorAdapter.class)
|
||||
private RGB textForegroundColor = new RGB( 0, 0, 0 );
|
||||
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(RGBColorAdapter.class)
|
||||
private RGB textBackgroundColor = new RGB( 255, 255, 255 );
|
||||
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(RGBColorAdapter.class)
|
||||
private RGB highlightTextForegroundColor = new RGB( 0, 0, 0 );
|
||||
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(RGBColorAdapter.class)
|
||||
private RGB highlightTextBackgroundColor = new RGB( 85, 152, 215 );
|
||||
|
||||
public Integer getDefaultNumEditors() {
|
||||
return defaultNumEditors;
|
||||
}
|
||||
|
||||
public void setDefaultNumEditors(Integer defaultNumEditors) {
|
||||
if( defaultNumEditors > 0 && defaultNumEditors < 100 ) { // sanity check
|
||||
this.defaultNumEditors = defaultNumEditors;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getMaxNumEditors() {
|
||||
return maxNumEditors;
|
||||
}
|
||||
|
||||
public void setMaxNumEditors(Integer maxNumEditors) {
|
||||
if( maxNumEditors > 0 && maxNumEditors < 200 ) { // sanity check
|
||||
this.maxNumEditors = maxNumEditors;
|
||||
}
|
||||
}
|
||||
|
||||
public FontSizeCfg getFontSizeCfg() {
|
||||
return fontSizeCfg;
|
||||
}
|
||||
|
||||
public void setFontSizeCfg(FontSizeCfg fontSizeCfg) {
|
||||
this.fontSizeCfg = fontSizeCfg;
|
||||
}
|
||||
|
||||
public static SizeButtonCfg getSelectedFontButton() {
|
||||
return selectedFontButton;
|
||||
}
|
||||
|
||||
public RGB getTextForegroundColor() {
|
||||
return textForegroundColor;
|
||||
}
|
||||
|
||||
public void setTextForegroundColor(RGB textForegroundColor) {
|
||||
this.textForegroundColor = textForegroundColor;
|
||||
}
|
||||
|
||||
public RGB getTextBackgroundColor() {
|
||||
return textBackgroundColor;
|
||||
}
|
||||
|
||||
public void setTextBackgroundColor(RGB textBackgroundColor) {
|
||||
this.textBackgroundColor = textBackgroundColor;
|
||||
}
|
||||
|
||||
public RGB getHighlightTextForegroundColor() {
|
||||
return highlightTextForegroundColor;
|
||||
}
|
||||
|
||||
public void setHighlightTextForegroundColor(RGB highlightTextForegroundColor) {
|
||||
this.highlightTextForegroundColor = highlightTextForegroundColor;
|
||||
}
|
||||
|
||||
public RGB getHighlightTextBackgroundColor() {
|
||||
return highlightTextBackgroundColor;
|
||||
}
|
||||
|
||||
public void setHighlightTextBackgroundColor(RGB highlightTextBackgroundColor) {
|
||||
this.highlightTextBackgroundColor = highlightTextBackgroundColor;
|
||||
}
|
||||
|
||||
private static TextEditorCfg textEditorCfg = null;
|
||||
|
||||
public static TextEditorCfg getTextEditorCfg() {
|
||||
|
||||
if( textEditorCfg == null ) {
|
||||
try {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
File path = pm.getStaticFile("textws/gui/TextEditorCfg.xml");
|
||||
if( path == null ) {
|
||||
throw new Exception("localization file textws/gui/TextEditorCfg.xml not found");
|
||||
}
|
||||
|
||||
textEditorCfg = JAXB.unmarshal(path, TextEditorCfg.class);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TextEditorDialog.class);
|
||||
statusHandler.handle(Priority.ERROR, "Error with TextEditorCfg.xml file. Using defaults: ", ex);
|
||||
textEditorCfg = new TextEditorCfg();
|
||||
}
|
||||
|
||||
FontSizeCfg fontSizeCfg = textEditorCfg.getFontSizeCfg();
|
||||
|
||||
if( fontSizeCfg == null ) {
|
||||
// set meaningful dflt values
|
||||
FontSizeCfg fscfg = new FontSizeCfg();
|
||||
fscfg.setButtons( new ArrayList<SizeButtonCfg>() );
|
||||
textEditorCfg.setFontSizeCfg( fscfg );
|
||||
}
|
||||
|
||||
// do some sanity checking
|
||||
if( fontSizeCfg.getButtons() == null ||
|
||||
fontSizeCfg.getButtons().isEmpty() ) {
|
||||
// default to 1 medium button
|
||||
selectedFontButton = new SizeButtonCfg();
|
||||
fontSizeCfg.setButtons( new ArrayList<SizeButtonCfg>() );
|
||||
fontSizeCfg.getButtons().add( selectedFontButton );
|
||||
}
|
||||
else {
|
||||
for( SizeButtonCfg buttonCfg : fontSizeCfg.getButtons()) {
|
||||
if( buttonCfg.isSelected() ) {
|
||||
if( selectedFontButton == null ) {
|
||||
selectedFontButton = buttonCfg;
|
||||
}
|
||||
else {
|
||||
buttonCfg.setSelected( false );
|
||||
System.out.println("Sanity check in textEditorCfg.xml file:" +
|
||||
" only 1 font button can be selected" );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( selectedFontButton == null ) {
|
||||
System.out.println("Sanity check in textEditorCfg.xml file:" +
|
||||
" no font button set asselected. Defaulting to the first" );
|
||||
selectedFontButton = fontSizeCfg.getButtons().get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return textEditorCfg;
|
||||
}
|
||||
}
|
|
@ -144,7 +144,6 @@ import com.raytheon.uf.edex.services.textdbsrv.IQueryTransport;
|
|||
import com.raytheon.uf.edex.wmo.message.WMOHeader;
|
||||
// import com.raytheon.uf.viz.core.RGBColors;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.auth.UserController;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.notification.INotificationObserver;
|
||||
import com.raytheon.uf.viz.core.notification.NotificationException;
|
||||
|
@ -323,11 +322,11 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
|
|||
* 31JAN2013 1563 rferrel Force location of airport tooltip.
|
||||
* 31JAN2013 1568 rferrel Spell checker now tied to this dialog instead of parent.
|
||||
* 26Apr2013 16123 snaples Removed setFocus to TextEditor in postExecute method.
|
||||
* 07Jun2013 1981 mpduff Add user id to OUPRequest as it is now protected.
|
||||
* 20Jun2013 15733 XHuang Add functionalities that get Font size, Text colors from
|
||||
* *.xml files in localization;
|
||||
* add selection listener to catch the highlight words and
|
||||
* set the highlight colors.
|
||||
* 20Jun2013 15733 XHuang Add functionalities that get Font size, Text colors from
|
||||
* *.xml files in localization;
|
||||
* add selection listener to catch the highlight words and
|
||||
* set the highlight colors.
|
||||
* 25July2013 15733 GHull Read font and color prefs from TextEditorCfg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -378,9 +377,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
|
||||
private final int HIGHLIGHT_BG = SWT.COLOR_RED;
|
||||
|
||||
// Color red = shell.getDisplay().getSystemColor(SWT.COLOR_RED);
|
||||
// Color black = shell.getDisplay().getSystemColor(SWT.COLOR_BLACK);
|
||||
|
||||
/**
|
||||
* The length of BEGIN_ELEMENT_TAG.
|
||||
*/
|
||||
|
@ -1023,11 +1019,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
*/
|
||||
private Font dftFont;
|
||||
|
||||
/**
|
||||
* default funt size.
|
||||
*/
|
||||
private final int DEFAULT_FUNT_SIZE = 11;
|
||||
|
||||
/**
|
||||
* Composite containing the editor buttons.
|
||||
*/
|
||||
|
@ -1389,8 +1380,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
private Color highlightBackground;
|
||||
|
||||
// protected Color color;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor with additional cave style rules
|
||||
*
|
||||
|
@ -1545,7 +1534,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
}
|
||||
|
||||
commandHistory = new CommandHistory();
|
||||
|
||||
|
||||
// Create the menus
|
||||
createMenus();
|
||||
|
||||
|
@ -2960,18 +2949,20 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
* The font size sub menu.
|
||||
*/
|
||||
private void createFontSizeSubMenu(Menu fontSizeSubMenu) {
|
||||
int selectFontSize = DEFAULT_FUNT_SIZE;
|
||||
|
||||
FontSizeCfg fontSizeCfg = getFontSizeCfg();
|
||||
FontSizeCfg fontSizeCfg = TextEditorCfg.getTextEditorCfg().getFontSizeCfg();
|
||||
SizeButtonCfg seldFontBtn = TextEditorCfg.getTextEditorCfg().getSelectedFontButton();
|
||||
|
||||
for (SizeButtonCfg buttonCfg : fontSizeCfg.getButtons()) {
|
||||
MenuItem item = new MenuItem(fontSizeSubMenu, SWT.RADIO);
|
||||
item.setText(buttonCfg.getLabelName());
|
||||
item.setSelection(buttonCfg.isSelected());
|
||||
item.setSelection( false );
|
||||
item.setData(buttonCfg);
|
||||
if (buttonCfg.isSizeEnabled() && buttonCfg.isSelected()) {
|
||||
selectFontSize = buttonCfg.getFontSize();
|
||||
|
||||
// if this button is the initial selection.
|
||||
if( seldFontBtn.getLabelName().equals( buttonCfg.getLabelName() ) ) {
|
||||
item.setSelection(true);
|
||||
setDefaultFont(selectFontSize);
|
||||
setDefaultFont( seldFontBtn.getFontSize(), seldFontBtn.getFontName() );
|
||||
}
|
||||
|
||||
item.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -2980,7 +2971,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
MenuItem item = (MenuItem) event.getSource();
|
||||
if (item.getSelection()) {
|
||||
int selectFontSize = ( (SizeButtonCfg) item.getData()).getFontSize();
|
||||
setDefaultFont(selectFontSize);
|
||||
String seldFontName = ((SizeButtonCfg) item.getData()).getFontName();
|
||||
|
||||
setDefaultFont( selectFontSize, seldFontName );
|
||||
|
||||
textEditor.setFont(dftFont);
|
||||
headerTF.setFont(dftFont);
|
||||
|
@ -2991,80 +2984,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
|
||||
}
|
||||
|
||||
private FontSizeCfg getFontSizeCfg() {
|
||||
FontSizeCfg fontSizeCfg = null;
|
||||
|
||||
try {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
File path = pm.getStaticFile("textws/gui/FontSizeCfg.xml");
|
||||
fontSizeCfg = JAXB.unmarshal(path, FontSizeCfg.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TextEditorDialog.class);
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to parse Autowrap menu configuration.", e);
|
||||
fontSizeCfg = new FontSizeCfg();
|
||||
|
||||
}
|
||||
|
||||
// Perform Sanity Checks on configuration.
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
// Check buttonCfg values.
|
||||
int selectionCnt = 0;
|
||||
String selectionLabel = null;
|
||||
if (fontSizeCfg.getButtons() != null) {
|
||||
for (SizeButtonCfg buttonCfg : fontSizeCfg.getButtons()) {
|
||||
if (buttonCfg.isSelected()) {
|
||||
++selectionCnt;
|
||||
if (selectionCnt == 1) {
|
||||
selectionLabel = buttonCfg.getLabelName();
|
||||
} else {
|
||||
buttonCfg.setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (buttonCfg.isSizeEnabled()) {
|
||||
int fntSize = buttonCfg.getFontSize();
|
||||
if (fntSize <= 0) {
|
||||
message.append("Item \"")
|
||||
.append(buttonCfg.getLabelName())
|
||||
.append("\" bad fntSize value (")
|
||||
.append(buttonCfg.getFontSize())
|
||||
.append(") changing to ")
|
||||
.append(DEFAULT_FUNT_SIZE).append("\n");
|
||||
buttonCfg.setFontSize(DEFAULT_FUNT_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selectionCnt == 0 && fontSizeCfg.getButtons().size() > 0) {
|
||||
SizeButtonCfg buttonCfg = fontSizeCfg.getButtons().get(0);
|
||||
message.append("No button selected. Selecting top item \"")
|
||||
.append(buttonCfg.getLabelName()).append("\"\n");
|
||||
buttonCfg.setSelected(true);
|
||||
} else if (selectionCnt > 1) {
|
||||
message.append(selectionCnt)
|
||||
.append(" items selected; will select item \"")
|
||||
.append(selectionLabel).append("\"\n");
|
||||
}
|
||||
|
||||
if (message.length() > 0) {
|
||||
message.insert(0, "FontSize problem(s): ");
|
||||
IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TextEditorDialog.class);
|
||||
statusHandler.handle(Priority.PROBLEM, message.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return fontSizeCfg;
|
||||
|
||||
}
|
||||
|
||||
public void setDefaultFont(int fontSize) {
|
||||
dftFont = new Font(getDisplay(), "Courier", fontSize, SWT.NORMAL);
|
||||
|
||||
public void setDefaultFont( int fontSize, String fontName ) {
|
||||
dftFont = new Font( getDisplay(), fontName, fontSize, SWT.NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3805,7 +3726,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
textEditorComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gridLayout = new GridLayout(1, false);
|
||||
TextColorsCfg textColorCfg = null;
|
||||
// TextColorsCfg textColorCfg = null;
|
||||
|
||||
textEditorComp.setLayout(gridLayout);
|
||||
textEditorComp.setLayoutData(gd);
|
||||
|
@ -3825,10 +3746,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
textEditor.setWordWrap(false);
|
||||
textEditor.setEditable(false);
|
||||
airportToolTip = new DefaultToolTip(textEditor, SWT.DEFAULT, true);
|
||||
textEditor.setKeyBinding(SWT.INSERT, SWT.NULL); // DR 7826
|
||||
textEditor.setKeyBinding(SWT.INSERT, SWT.NULL); // DR 7826
|
||||
|
||||
textColorCfg = getTextColorCfg();
|
||||
setDefaultTextColor(textColorCfg);
|
||||
// textColorCfg = getTextColorCfg();
|
||||
setDefaultTextColor( TextEditorCfg.getTextEditorCfg() );
|
||||
textEditor.setForeground(textForeground);
|
||||
textEditor.setBackground(textBackground);
|
||||
|
||||
|
@ -4029,83 +3950,41 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
});
|
||||
}
|
||||
|
||||
private TextColorsCfg getTextColorCfg() {
|
||||
TextColorsCfg textColorsCfg = null;
|
||||
|
||||
try {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
File path = pm.getStaticFile("textws/gui/TextColorsCfg.xml");
|
||||
textColorsCfg = JAXB.unmarshal(path, TextColorsCfg.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TextEditorDialog.class);
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to parse TextColors configuration.", e);
|
||||
textColorsCfg = new TextColorsCfg();
|
||||
|
||||
}
|
||||
|
||||
// Perform Sanity Checks on configuration.
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
for (TextColorElement textElm : textColorsCfg.getTextColorElements()) {
|
||||
String prmtName = textElm.getParamName();
|
||||
if (prmtName == null) {
|
||||
message.append("Item \"paramName\" problem!\n");
|
||||
|
||||
}
|
||||
|
||||
if( textElm.getColor() == null ) {
|
||||
message.append("Item \"color\" data enter problem!\n");
|
||||
}
|
||||
|
||||
if (message.length() > 0) {
|
||||
message.insert(0, "TextColorsCfg broblem(s): ");
|
||||
IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TextEditorDialog.class);
|
||||
statusHandler.handle(Priority.PROBLEM, message.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return textColorsCfg;
|
||||
|
||||
}
|
||||
// private TextColorsCfg getTextColorCfg() {
|
||||
// TextColorsCfg textColorsCfg = TextEditorCfg.getTextEditorCfg().getTextColorsCfg();
|
||||
//
|
||||
// // Perform Sanity Checks on configuration.
|
||||
// StringBuilder message = new StringBuilder();
|
||||
//
|
||||
// for (TextColorElement textElm : textColorsCfg.getTextColorElements()) {
|
||||
// String prmtName = textElm.getParamName();
|
||||
// if (prmtName == null) {
|
||||
// message.append("Item \"paramName\" problem!\n");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if( textElm.getColor() == null ) {
|
||||
// message.append("Item \"color\" data enter problem!\n");
|
||||
// }
|
||||
//
|
||||
// if (message.length() > 0) {
|
||||
// message.insert(0, "TextColorsCfg broblem(s): ");
|
||||
// IUFStatusHandler statusHandler = UFStatus
|
||||
// .getHandler(TextEditorDialog.class);
|
||||
// statusHandler.handle(Priority.PROBLEM, message.toString());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// return textColorsCfg;
|
||||
// }
|
||||
|
||||
private void setDefaultTextColor(TextColorsCfg clrCfg) {
|
||||
|
||||
for (TextColorElement textElm : clrCfg.getTextColorElements()) {
|
||||
|
||||
String paramName = textElm.getParamName().trim();
|
||||
if( paramName.equalsIgnoreCase("textBG")) {
|
||||
if ( textElm.getColor() != null)
|
||||
textBackground = new Color(shell.getDisplay(), textElm.getColor());
|
||||
else
|
||||
textBackground = shell.getDisplay().getSystemColor(UPDATE_BG);
|
||||
|
||||
}
|
||||
else if( paramName.equalsIgnoreCase("textFG")) {
|
||||
if ( textElm.getColor() != null)
|
||||
textForeground = new Color(shell.getDisplay(), textElm.getColor());
|
||||
else
|
||||
textForeground = shell.getDisplay().getSystemColor(UPDATE_FG);
|
||||
}
|
||||
else if( paramName.equalsIgnoreCase("highlightBG")) {
|
||||
if ( textElm.getColor() != null)
|
||||
highlightBackground = new Color(shell.getDisplay(), textElm.getColor());
|
||||
else
|
||||
highlightBackground = shell.getDisplay().getSystemColor(HIGHLIGHT_BG);
|
||||
}
|
||||
else if( paramName.equalsIgnoreCase("highlightFG")) {
|
||||
if ( textElm.getColor() != null)
|
||||
highlightForeground = new Color(shell.getDisplay(), textElm.getColor());
|
||||
else
|
||||
highlightForeground = shell.getDisplay().getSystemColor(UPDATE_FG);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setDefaultTextColor(TextEditorCfg txtClrCfg ) {
|
||||
|
||||
textBackground = new Color( shell.getDisplay(), txtClrCfg.getTextBackgroundColor() );
|
||||
textForeground = new Color(shell.getDisplay(), txtClrCfg.getTextForegroundColor() );
|
||||
highlightBackground = new Color(shell.getDisplay(), txtClrCfg.getHighlightTextBackgroundColor() );
|
||||
highlightForeground = new Color(shell.getDisplay(), txtClrCfg.getHighlightTextForegroundColor() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5123,7 +5002,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
}
|
||||
req.setCheckBBB(true);
|
||||
req.setProduct(oup);
|
||||
req.setUser(UserController.getUserObject());
|
||||
|
||||
// Code in Run statement goes here!
|
||||
new Thread(new ThriftClientRunnable(req)).start();
|
||||
|
@ -5712,25 +5590,27 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
int afosXxxLimit = 5; // second three characters is AFOS XXX
|
||||
|
||||
/*
|
||||
* DR15610 - Make sure that if the first line of the text product is not
|
||||
* a WMO heading it is treated as part of the text body.
|
||||
* DR15610 - Make sure that if the first line of the
|
||||
* text product is not a WMO heading it is treated as
|
||||
* part of the text body.
|
||||
*/
|
||||
String[] pieces = textEditor.getText().split("\r*\n", 2);
|
||||
if (pieces.length > 1) {
|
||||
pieces[0] += "\n"; // WMOHeader expects this
|
||||
}
|
||||
WMOHeader header = new WMOHeader(pieces[0].getBytes(), null);
|
||||
if (!header.isValid()) {
|
||||
headerTF.setText("");
|
||||
try {
|
||||
textEditor.setText(originalText);
|
||||
textEditor.setEditable(true);
|
||||
textEditor.setEditable(false);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// There is no text product body, so set it to the empty string.
|
||||
textEditor.setText("");
|
||||
}
|
||||
} else {
|
||||
if ( !header.isValid() ) {
|
||||
headerTF.setText("");
|
||||
try {
|
||||
textEditor.setText(originalText);
|
||||
textEditor.setEditable(true);
|
||||
textEditor.setEditable(false);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// There is no text product body, so set it to the empty string.
|
||||
textEditor.setText("");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO FIX PARSING
|
||||
|
||||
// First, set the current header by assuming that it usually
|
||||
|
@ -5738,8 +5618,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
// though there will be exceptions to that "rule" as handled below.
|
||||
// So, obtain the AFOS NNNxxx. If it's where it is supposed to be
|
||||
// in the new format, then the existing header is already an AWIPS
|
||||
// text product identifier. Otherwise it is a legacy AFOS
|
||||
// identifier.
|
||||
// text product identifier. Otherwise it is a legacy AFOS identifier.
|
||||
if (TextDisplayModel.getInstance().hasStdTextProduct(token)) {
|
||||
StdTextProduct textProd = TextDisplayModel.getInstance()
|
||||
.getStdTextProduct(token);
|
||||
|
@ -5749,16 +5628,14 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
start = textEditor.getOffsetAtLine(thisLine + 1);
|
||||
if ((textEditor.getText(start, start + afosNnnLimit)
|
||||
.equals(prodId.getNnnid()))
|
||||
&& (textEditor.getText(start + afosNnnLimit + 1,
|
||||
start + afosXxxLimit).equals(prodId
|
||||
.getXxxid()))) {
|
||||
&& (textEditor.getText(start + afosNnnLimit + 1, start
|
||||
+ afosXxxLimit).equals(prodId.getXxxid()))) {
|
||||
// Text matches the products nnnid and xxxid
|
||||
numberOfLinesOfHeaderText = 2;
|
||||
} else if (textEditor.getText(start,
|
||||
start + afosNnnLimit + 2).equals(
|
||||
AFOSParser.DRAFT_PIL)
|
||||
|| textEditor.getText(start,
|
||||
start + afosNnnLimit + 2).equals("TTAA0")) {
|
||||
} else if (textEditor.getText(start, start + afosNnnLimit + 2)
|
||||
.equals(AFOSParser.DRAFT_PIL)
|
||||
|| textEditor.getText(start, start + afosNnnLimit + 2)
|
||||
.equals("TTAA0")) {
|
||||
// Text matches temporary WRKWG#
|
||||
numberOfLinesOfHeaderText = 2;
|
||||
} else {
|
||||
|
@ -5798,8 +5675,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
String line = null;
|
||||
do {
|
||||
numberOfBlankLines++;
|
||||
line = textEditor.getLine(thisLine
|
||||
+ numberOfLinesOfHeaderText + numberOfBlankLines);
|
||||
line = textEditor.getLine(thisLine + numberOfLinesOfHeaderText
|
||||
+ numberOfBlankLines);
|
||||
} while (line.length() == 0 || line.equals(""));
|
||||
// Note: 'st' is a reference to 'textEditor'...
|
||||
// delelete the header from the text in 'textEditor'
|
||||
|
@ -6104,7 +5981,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
if ("MTR".equals(stdProdId.getNnnid())
|
||||
&& (commandText.startsWith("ALL:")
|
||||
|| commandText.startsWith("A:") || commandText
|
||||
.endsWith("000"))) {
|
||||
.endsWith("000"))) {
|
||||
stripWMOHeaders(prod);
|
||||
}
|
||||
|
||||
|
@ -7197,7 +7074,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
|| line.endsWith("ADVISORY")
|
||||
|| line.endsWith("ADVISORY...TEST")
|
||||
|| line.endsWith("ADVISORY...CORRECTED") || line
|
||||
.endsWith("ADVISORY...CORRECTED...TEST"))) {
|
||||
.endsWith("ADVISORY...CORRECTED...TEST"))) {
|
||||
line += "...RESENT";
|
||||
updatedMND = true;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.raytheon.viz.texteditor.TextWorkstationConstants;
|
|||
import com.raytheon.viz.texteditor.alarmalert.dialogs.CurrentAlarmQueue;
|
||||
import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertFunctions;
|
||||
import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertNotificationObserver;
|
||||
import com.raytheon.viz.texteditor.dialogs.TextEditorCfg;
|
||||
import com.raytheon.viz.texteditor.dialogs.TextEditorDialog;
|
||||
import com.raytheon.viz.texteditor.msgs.ITextEditorCallback;
|
||||
import com.raytheon.viz.texteditor.msgs.ITextWorkstationCallback;
|
||||
|
@ -92,6 +93,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 13Dec2012 1353 rferrel Fix bug introduced in the Show all dialogs.
|
||||
* 30Jan2013 DR 14736 D. Friedman Display local time.
|
||||
* 24Jun2013 DR 15733 XHuang Display MAX_BUTTON_CNT (8 button).
|
||||
* 25July2013 DR 15733 Greg Hull Make dflt and max number of Text Buttons configurable.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -100,9 +102,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
public class TextWorkstationDlg extends CaveSWTDialog implements
|
||||
ITextEditorCallback, INotificationObserver {
|
||||
|
||||
private final int INIT_BUTTON_CNT = 4;
|
||||
private int INIT_BUTTON_CNT = 4;
|
||||
|
||||
private final int MAX_BUTTON_CNT = 8;
|
||||
private int MAX_BUTTON_CNT = 8;
|
||||
|
||||
private String productToDisplay = null;
|
||||
|
||||
|
@ -203,6 +205,9 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
fontAwipsLabel = new Font(shell.getDisplay(), "Helvetica", 24,
|
||||
SWT.ITALIC);
|
||||
|
||||
INIT_BUTTON_CNT = TextEditorCfg.getTextEditorCfg().getDefaultNumEditors();
|
||||
MAX_BUTTON_CNT = TextEditorCfg.getTextEditorCfg().getMaxNumEditors();
|
||||
|
||||
// Initialize all of the controls and layouts
|
||||
initializeComponents();
|
||||
}
|
||||
|
@ -437,7 +442,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
|
|||
textBtnArray = new ArrayList<Button>();
|
||||
textEditorArray = new ArrayList<TextEditorDialog>();
|
||||
|
||||
for (int x = 1; x <= MAX_BUTTON_CNT; ++x) {
|
||||
for (int x = 1; x <= INIT_BUTTON_CNT; ++x) {
|
||||
createButtonAndTextEditor(x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.vividsolutions.jts.geom.Envelope;
|
|||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import com.vividsolutions.jts.geom.LineSegment;
|
||||
import com.vividsolutions.jts.geom.LinearRing;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
|
||||
|
@ -68,8 +69,10 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
|||
* 06/17/2013 DR 15787 Qinglu Lin Added removeOverlaidLinesegments() and removeTriplyOverlaidLinesegments().
|
||||
* 07/11/2013 DR 16376 Qinglu Lin Removed removeTriplyOverlaidLinesegments() and updated computeSlope()
|
||||
* and removeOverlaidLinesegments().
|
||||
|
||||
*
|
||||
* 07/25/2013 DR 16376 Qinglu Lin Move adjustVertex() and computeSlope() here from WarngenLayer; replaced
|
||||
* the call to removeIntersectedSeg() with a call to adjustVertex(); updated
|
||||
* removeDuplicateCoordinate(), computeCoordinate(), adjustPolygon() prolog, and
|
||||
* removeOverlaidLinesegments(); added alterVertexes() and calcShortestDistance().
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
|
@ -441,13 +444,13 @@ public class PolygonUtil {
|
|||
|
||||
if (rval.isValid() == false) {
|
||||
System.out.println("Fixing intersected segments");
|
||||
points.remove(points.size() - 1);
|
||||
removeIntersectedSeg(points);
|
||||
points.add(new Coordinate(points.get(0)));
|
||||
rval = gf.createPolygon(gf.createLinearRing(points
|
||||
.toArray(new Coordinate[points.size()])), null);
|
||||
Coordinate[] coords = rval.getCoordinates();
|
||||
adjustVertex(coords);
|
||||
PolygonUtil.round(coords, 2);
|
||||
coords = PolygonUtil.removeDuplicateCoordinate(coords);
|
||||
coords = PolygonUtil.removeOverlaidLinesegments(coords);
|
||||
rval = gf.createPolygon(gf.createLinearRing(coords), null);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -1090,13 +1093,20 @@ public class PolygonUtil {
|
|||
if (polygon == null) {
|
||||
return null;
|
||||
}
|
||||
Coordinate[] coords = removeDuplicateCoordinate(polygon.getCoordinates());
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
return gf.createPolygon(gf.createLinearRing(coords), null);
|
||||
}
|
||||
|
||||
Coordinate[] verts = polygon.getCoordinates();
|
||||
public static Coordinate[] removeDuplicateCoordinate(Coordinate[] verts) {
|
||||
if (verts == null) {
|
||||
return null;
|
||||
}
|
||||
Set<Coordinate> coords = new LinkedHashSet<Coordinate>();
|
||||
for (Coordinate c : verts)
|
||||
coords.add(c);
|
||||
if ((verts.length - coords.size()) < 2)
|
||||
return polygon;
|
||||
return verts;
|
||||
Coordinate[] vertices = new Coordinate[coords.size() + 1];
|
||||
Iterator<Coordinate> iter = coords.iterator();
|
||||
int i = 0;
|
||||
|
@ -1105,8 +1115,7 @@ public class PolygonUtil {
|
|||
i += 1;
|
||||
}
|
||||
vertices[i] = new Coordinate(vertices[0]);
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
return gf.createPolygon(gf.createLinearRing(vertices), null);
|
||||
return vertices;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1226,6 +1235,8 @@ public class PolygonUtil {
|
|||
c[j].y = y;
|
||||
if (j == 0)
|
||||
c[c.length - 1] = c[j];
|
||||
if (j == c.length - 1)
|
||||
c[0] = c[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1233,8 +1244,7 @@ public class PolygonUtil {
|
|||
/**
|
||||
* adjustPolygon When a point is very close to a line in the initial warning
|
||||
* polygon, the resulting coordinates cause the failure of polygon drawing
|
||||
* in follow-up. The method move that kind of points away from the line, and
|
||||
* return a Polygon.
|
||||
* in follow-up. The method move that kind of points away from the line.
|
||||
*
|
||||
* History 12/06/2012 DR 15559 Qinglu Lin Created.
|
||||
*/
|
||||
|
@ -1276,7 +1286,7 @@ public class PolygonUtil {
|
|||
slope1 = slope;
|
||||
count += 1;
|
||||
} else {
|
||||
if (Math.abs(slope - slope1) < min) {
|
||||
if (Math.abs(Math.abs(slope) - Math.abs(slope1)) <= min) {
|
||||
count += 1;
|
||||
} else {
|
||||
count = 0;
|
||||
|
@ -1310,4 +1320,186 @@ public class PolygonUtil {
|
|||
}
|
||||
return coords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust the location of one vertex that cause polygon self-crossing.
|
||||
*/
|
||||
static public Coordinate[] adjustVertex(Coordinate[] coord) {
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
LinearRing lr;
|
||||
Polygon p;
|
||||
int length = coord.length;
|
||||
Coordinate intersectCoord = null;
|
||||
int index[] = new int[6];
|
||||
LineSegment ls1, ls2;
|
||||
double d[] = new double[6];
|
||||
int indexOfTheOtherEnd[] = new int[2];
|
||||
boolean isPolygonValid = false;
|
||||
outerLoop: for (int skippedSegment = 1; skippedSegment < length - 3; skippedSegment++) {
|
||||
for (int i = 0; i < length - 1; i++) {
|
||||
index[0] = i;
|
||||
index[1] = index[0] + 1;
|
||||
index[2] = index[1] + skippedSegment;
|
||||
if (index[2] >= length)
|
||||
index[2] = index[2] - length + 1;
|
||||
index[3] = index[2] + 1;
|
||||
if (index[3] >= length)
|
||||
index[3] = index[3] - length + 1;
|
||||
ls1 = new LineSegment(coord[index[0]], coord[index[1]]);
|
||||
ls2 = new LineSegment(coord[index[2]], coord[index[3]]);
|
||||
intersectCoord = ls1.intersection(ls2);
|
||||
if (intersectCoord != null) {
|
||||
for (int j = 0; j < index.length - 2; j++) {
|
||||
d[j] = intersectCoord.distance(coord[index[j]]);
|
||||
}
|
||||
if (d[0] < d[1]) {
|
||||
index[4] = index[0];
|
||||
d[4] = d[0];
|
||||
indexOfTheOtherEnd[0] = index[1];
|
||||
} else {
|
||||
index[4] = index[1];
|
||||
d[4] = d[1];
|
||||
indexOfTheOtherEnd[0] = index[0];
|
||||
}
|
||||
if (d[2] < d[3]) {
|
||||
index[5] = index[2];
|
||||
d[5] = d[2];
|
||||
indexOfTheOtherEnd[1] = index[3];
|
||||
} else {
|
||||
index[5] = index[3];
|
||||
d[5] = d[3];
|
||||
indexOfTheOtherEnd[1] = index[2];
|
||||
}
|
||||
// index of the vertex on a line segment (line segment A),
|
||||
// which will be moved along line segment A.
|
||||
int replaceIndex;
|
||||
// index of the vertex at the other end of line segment A.
|
||||
int theOtherIndex;
|
||||
if (d[4] < d[5]) {
|
||||
replaceIndex = index[4];
|
||||
theOtherIndex = indexOfTheOtherEnd[0];
|
||||
} else {
|
||||
replaceIndex = index[5];
|
||||
theOtherIndex = indexOfTheOtherEnd[1];
|
||||
}
|
||||
// move the bad vertex, which is on line segment A and has
|
||||
// the shortest distance to intersectCoord,
|
||||
// along line segment A to the other side of line segment B
|
||||
// which intersects with line segment A.
|
||||
double delta;
|
||||
double min = 0.00001;
|
||||
if (Math.abs(intersectCoord.x - coord[replaceIndex].x) < min) {
|
||||
// move the bad vertex along a vertical line segment.
|
||||
delta = intersectCoord.y - coord[theOtherIndex].y;
|
||||
coord[replaceIndex].y += 0.01 * (delta / Math
|
||||
.abs(delta));
|
||||
} else if (Math.abs(intersectCoord.y
|
||||
- coord[replaceIndex].y) < min) {
|
||||
// move the bad vertex along a horizontal line segment.
|
||||
delta = intersectCoord.x - coord[theOtherIndex].x;
|
||||
coord[replaceIndex].x += 0.01 * (delta / Math
|
||||
.abs(delta));
|
||||
} else {
|
||||
// move the bad vertex along a line segment which is
|
||||
// neither vertical nor horizontal.
|
||||
double slope = computeSlope(coord, replaceIndex,
|
||||
theOtherIndex);
|
||||
delta = coord[theOtherIndex].y - intersectCoord.y;
|
||||
coord[replaceIndex].y = intersectCoord.y + 0.005
|
||||
* (delta / Math.abs(delta));
|
||||
coord[replaceIndex].x = (coord[replaceIndex].y - coord[theOtherIndex].y)
|
||||
/ slope + coord[theOtherIndex].x;
|
||||
}
|
||||
//PolygonUtil.round(coord, 2);
|
||||
PolygonUtil.round(coord[replaceIndex], 2);
|
||||
if (replaceIndex == 0)
|
||||
coord[length - 1] = new Coordinate(coord[replaceIndex]);
|
||||
else if (replaceIndex == length - 1)
|
||||
coord[0] = new Coordinate(coord[replaceIndex]);
|
||||
lr = gf.createLinearRing(coord);
|
||||
p = gf.createPolygon(lr, null);
|
||||
isPolygonValid = p.isValid();
|
||||
if (isPolygonValid)
|
||||
break outerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
return coord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the location of two vertexes that cause polygon self-crossing.
|
||||
* This method would be used if polygon is still invalid after using adjustVertex().
|
||||
*/
|
||||
static public Coordinate[] alterVertexes(Coordinate[] coord) {
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
LinearRing lr;
|
||||
Polygon p;
|
||||
int length = coord.length;
|
||||
Coordinate intersectCoord = null;
|
||||
int index[] = new int[6];
|
||||
LineSegment ls1, ls2;
|
||||
boolean isPolygonValid = false;
|
||||
int index1, index2;
|
||||
outerLoop: for (int skippedSegment = 1; skippedSegment < length - 3; skippedSegment++) {
|
||||
for (int i = 0; i < length - 1; i++) {
|
||||
index[0] = i;
|
||||
index[1] = index[0] + 1;
|
||||
index[2] = index[1] + skippedSegment;
|
||||
if (index[2] >= length)
|
||||
index[2] = index[2] - length + 1;
|
||||
index[3] = index[2] + 1;
|
||||
if (index[3] >= length)
|
||||
index[3] = index[3] - length + 1;
|
||||
ls1 = new LineSegment(coord[index[0]], coord[index[1]]);
|
||||
ls2 = new LineSegment(coord[index[2]], coord[index[3]]);
|
||||
intersectCoord = null;
|
||||
intersectCoord = ls1.intersection(ls2);
|
||||
if (intersectCoord != null) {
|
||||
index1 = calcShortestDistance(intersectCoord, ls1);
|
||||
index2 = calcShortestDistance(intersectCoord, ls2);
|
||||
Coordinate c = new Coordinate(0.5*(coord[index1].x + coord[2+index2].x),
|
||||
0.5*(coord[index1].y + coord[2+index2].y));
|
||||
PolygonUtil.round(c, 2);
|
||||
coord[index[index1]] = new Coordinate(c);
|
||||
coord[index[2+index2]] = new Coordinate(c);
|
||||
if (index[index1] == 0) {
|
||||
coord[coord.length-1] = new Coordinate(c);
|
||||
} else if (index[index1] == coord.length-1) {
|
||||
coord[0] = new Coordinate(c);
|
||||
}
|
||||
if (index[2+index2] == 0) {
|
||||
coord[coord.length-1] = new Coordinate(c);
|
||||
} else if (index[2+index2] == coord.length-1) {
|
||||
coord[0] = new Coordinate(c);
|
||||
}
|
||||
lr = gf.createLinearRing(coord);
|
||||
p = gf.createPolygon(lr, null);
|
||||
isPolygonValid = p.isValid();
|
||||
if (isPolygonValid)
|
||||
break outerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
return coord;
|
||||
}
|
||||
|
||||
static public int calcShortestDistance(Coordinate p, LineSegment ls) {
|
||||
double d1 = p.distance(ls.p0);
|
||||
double d2 = p.distance(ls.p1);
|
||||
if (d1 <= d2)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
static public double computeSlope(Coordinate[] coords, int i, int j) {
|
||||
double min = 1.0E-08;
|
||||
double dx = coords[i].x - coords[j].x;
|
||||
double slope = 0.0;
|
||||
if (Math.abs(dx) > min) {
|
||||
slope = (coords[i].y - coords[j].y) / dx;
|
||||
}
|
||||
return slope;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ import com.vividsolutions.jts.geom.Polygon;
|
|||
* May 17, 2013 2012 jsanchez Preserved the warned area if the hatched area source is the same when changing templates.
|
||||
* Jun 24, 2013 DR 16317 D. Friedman Handle "motionless" track.
|
||||
* Jul 16, 2013 DR 16387 Qinglu Lin Reset totalSegments for each followup product.
|
||||
* Jul 29, 2013 DR 16352 D. Friedman Move 'result' to okPressed().
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -168,8 +169,6 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
}.schedule();
|
||||
}
|
||||
|
||||
private String result;
|
||||
|
||||
private static String UPDATELISTTEXT = "UPDATE LIST ";
|
||||
|
||||
public static String NO_BACKUP_SELECTED = "none";
|
||||
|
@ -1012,7 +1011,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
.getCurrent().getActiveShell());
|
||||
pmd.setCancelable(false);
|
||||
|
||||
result = null;
|
||||
final String[] resultContainer = new String[1];
|
||||
|
||||
try {
|
||||
pmd.run(false, false, new IRunnableWithProgress() {
|
||||
|
@ -1022,9 +1021,10 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
try {
|
||||
monitor.beginTask("Generating product", 1);
|
||||
long t0 = System.currentTimeMillis();
|
||||
result = TemplateRunner.runTemplate(warngenLayer,
|
||||
String result = TemplateRunner.runTemplate(warngenLayer,
|
||||
startTime.getTime(), endTime.getTime(),
|
||||
selectedBullets, followupData, backupData);
|
||||
resultContainer[0] = result;
|
||||
Matcher m = FollowUpUtil.vtecPtrn.matcher(result);
|
||||
totalSegments = 0;
|
||||
while (m.find()) {
|
||||
|
@ -1056,6 +1056,7 @@ public class WarngenDialog extends CaveSWTDialog implements
|
|||
// Launch the text editor display as the warngen editor
|
||||
// dialog using the result aka the warngen text product.
|
||||
try {
|
||||
String result = resultContainer[0];
|
||||
if (result != null) {
|
||||
wed.setTextWarngenDisplay(result, true);
|
||||
updateWarngenUIState(result);
|
||||
|
|
|
@ -182,6 +182,8 @@ import com.vividsolutions.jts.io.WKTReader;
|
|||
* 06/24/2013 DR 16317 D. Friedman Handle "motionless" track.
|
||||
* 06/25/2013 DR 16013 Qinglu Lin Added setUniqueFip() and code for re-hatching polygon.
|
||||
* 07/09/2013 DR 16376 Qinglu Lin Removed calling removeOverTriplylaidLinesegment() but called removeOverlaidLinesegment().
|
||||
* 07/26/2013 DR 16376 Qinglu Lin Moved adjustVertex() and computeSlope() to PolygonUtil; removed calculateDistance();
|
||||
* updated AreaHatcher's run().
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
|
@ -404,7 +406,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
|
|||
}
|
||||
|
||||
try {
|
||||
warningPolygon = PolygonUtil.removeDuplicateCoordinate(warningPolygon);
|
||||
warningPolygon = PolygonUtil.removeDuplicateCoordinate(warningPolygon);
|
||||
Polygon hatched = polygonUtil.hatchWarningArea(
|
||||
warningPolygon,
|
||||
removeCounties(warningArea,
|
||||
|
@ -415,12 +417,50 @@ public class WarngenLayer extends AbstractStormTrackResource {
|
|||
Coordinate[] coords = hatched.getCoordinates();
|
||||
PolygonUtil.round(coords, 2);
|
||||
PolygonUtil.adjustPolygon(coords);
|
||||
PolygonUtil.removeOverlaidLinesegments(coords);
|
||||
PolygonUtil.round(coords, 2);
|
||||
coords = PolygonUtil.removeDuplicateCoordinate(coords);
|
||||
coords = PolygonUtil.removeOverlaidLinesegments(coords);
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
LinearRing lr = gf.createLinearRing(coords);
|
||||
hatchedArea = gf.createPolygon(lr, null);
|
||||
if (!hatchedArea.isValid()) {
|
||||
hatchedArea = adjustVertex(hatchedArea);
|
||||
int adjustPolygon_counter = 0;
|
||||
while (!hatchedArea.isValid() && adjustPolygon_counter < 1) {
|
||||
System.out.println("Calling adjustPolygon #" + adjustPolygon_counter);
|
||||
PolygonUtil.adjustPolygon(coords);
|
||||
PolygonUtil.round(coords, 2);
|
||||
coords = PolygonUtil.removeDuplicateCoordinate(coords);
|
||||
coords = PolygonUtil.removeOverlaidLinesegments(coords);
|
||||
lr = gf.createLinearRing(coords);
|
||||
hatchedArea = gf.createPolygon(lr, null);
|
||||
adjustPolygon_counter += 1;
|
||||
}
|
||||
int counter = 0;
|
||||
if (!hatchedArea.isValid() && counter < 2) {
|
||||
System.out.println("calling adjustVertex & alterVertexes: loop #" + counter);
|
||||
int adjustVertex_counter = 0;
|
||||
lr = gf.createLinearRing(coords);
|
||||
hatchedArea = gf.createPolygon(lr, null);
|
||||
while (!hatchedArea.isValid() && adjustVertex_counter < 5) {
|
||||
System.out.println(" Calling adjustVertex #" + adjustVertex_counter);
|
||||
coords = PolygonUtil.adjustVertex(coords);
|
||||
coords = PolygonUtil.removeDuplicateCoordinate(coords);
|
||||
coords = PolygonUtil.removeOverlaidLinesegments(coords);
|
||||
lr = gf.createLinearRing(coords);
|
||||
hatchedArea = gf.createPolygon(lr, null);
|
||||
adjustVertex_counter += 1;
|
||||
}
|
||||
int inner_counter = 0;
|
||||
System.out.println("");
|
||||
while (!hatchedArea.isValid() && inner_counter < 5) {
|
||||
System.out.println(" Calling alterVertexes #" + inner_counter);
|
||||
coords = PolygonUtil.alterVertexes(coords);
|
||||
coords = PolygonUtil.removeDuplicateCoordinate(coords);
|
||||
coords = PolygonUtil.removeOverlaidLinesegments(coords);
|
||||
lr = gf.createLinearRing(coords);
|
||||
hatchedArea = gf.createPolygon(lr, null);
|
||||
inner_counter += 1;
|
||||
}
|
||||
counter += 1;
|
||||
}
|
||||
hatchedWarningArea = createWarnedArea(
|
||||
latLonToLocal(hatchedArea),
|
||||
|
@ -2993,126 +3033,6 @@ public class WarngenLayer extends AbstractStormTrackResource {
|
|||
this.warningAction = warningAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust the location of vertexes that cause polygon self-crossing.
|
||||
*/
|
||||
private Polygon adjustVertex(Polygon p) {
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
LinearRing lr;
|
||||
Coordinate coord[] = p.getCoordinates();
|
||||
int length = coord.length;
|
||||
Coordinate intersectCoord = null;
|
||||
int index[] = new int[6];
|
||||
LineSegment ls1, ls2;
|
||||
double d[] = new double[6];
|
||||
int indexOfTheOtherEnd[] = new int[2];
|
||||
boolean isPolygonValid = false;
|
||||
outerLoop: for (int skippedSegment = 1; skippedSegment < length - 3; skippedSegment++) {
|
||||
for (int i = 0; i < length - 1; i++) {
|
||||
index[0] = i;
|
||||
index[1] = index[0] + 1;
|
||||
index[2] = index[1] + skippedSegment;
|
||||
if (index[2] >= length)
|
||||
index[2] = index[2] - length + 1;
|
||||
index[3] = index[2] + 1;
|
||||
if (index[3] >= length)
|
||||
index[3] = index[3] - length + 1;
|
||||
ls1 = new LineSegment(coord[index[0]], coord[index[1]]);
|
||||
ls2 = new LineSegment(coord[index[2]], coord[index[3]]);
|
||||
intersectCoord = ls1.intersection(ls2);
|
||||
if (intersectCoord != null) {
|
||||
for (int j = 0; j < index.length - 2; j++) {
|
||||
d[j] = calculateDistance(intersectCoord,
|
||||
coord[index[j]]);
|
||||
}
|
||||
if (d[0] < d[1]) {
|
||||
index[4] = index[0];
|
||||
d[4] = d[0];
|
||||
indexOfTheOtherEnd[0] = index[1];
|
||||
} else {
|
||||
index[4] = index[1];
|
||||
d[4] = d[1];
|
||||
indexOfTheOtherEnd[0] = index[0];
|
||||
}
|
||||
if (d[2] < d[3]) {
|
||||
index[5] = index[2];
|
||||
d[5] = d[2];
|
||||
indexOfTheOtherEnd[1] = index[3];
|
||||
} else {
|
||||
index[5] = index[3];
|
||||
d[5] = d[3];
|
||||
indexOfTheOtherEnd[1] = index[2];
|
||||
}
|
||||
// index of the vertex on a line segment (line segment A),
|
||||
// which will be moved along line segment A.
|
||||
int replaceIndex;
|
||||
// index of the vertex at the other end of line segment A.
|
||||
int theOtherIndex;
|
||||
if (d[4] < d[5]) {
|
||||
replaceIndex = index[4];
|
||||
theOtherIndex = indexOfTheOtherEnd[0];
|
||||
} else {
|
||||
replaceIndex = index[5];
|
||||
theOtherIndex = indexOfTheOtherEnd[1];
|
||||
}
|
||||
// move the bad vertex, which is on line segment A and has
|
||||
// the shortest distance to intersectCoord,
|
||||
// along line segment A to the other side of line segment B
|
||||
// which intersects with line segment A.
|
||||
double delta;
|
||||
double min = 0.00001;
|
||||
if (Math.abs(intersectCoord.x - coord[replaceIndex].x) < min) {
|
||||
// move the bad vertex along a vertical line segment.
|
||||
delta = intersectCoord.y - coord[theOtherIndex].y;
|
||||
coord[replaceIndex].y += 0.01 * (delta / Math
|
||||
.abs(delta));
|
||||
} else if (Math.abs(intersectCoord.y
|
||||
- coord[replaceIndex].y) < min) {
|
||||
// move the bad vertex along a horizontal line segment.
|
||||
delta = intersectCoord.x - coord[theOtherIndex].x;
|
||||
coord[replaceIndex].x += 0.01 * (delta / Math
|
||||
.abs(delta));
|
||||
} else {
|
||||
// move the bad vertex along a line segment which is
|
||||
// neither vertical nor horizontal.
|
||||
double slope = computeSlope(coord, replaceIndex,
|
||||
theOtherIndex);
|
||||
delta = coord[theOtherIndex].y - intersectCoord.y;
|
||||
coord[replaceIndex].y = intersectCoord.y + 0.005
|
||||
* (delta / Math.abs(delta));
|
||||
coord[replaceIndex].x = (coord[replaceIndex].y - coord[theOtherIndex].y)
|
||||
/ slope + coord[theOtherIndex].x;
|
||||
}
|
||||
PolygonUtil.round(coord, 2);
|
||||
if (replaceIndex == 0)
|
||||
coord[length - 1] = new Coordinate(coord[replaceIndex]);
|
||||
else if (replaceIndex == length - 1)
|
||||
coord[0] = new Coordinate(coord[replaceIndex]);
|
||||
lr = gf.createLinearRing(coord);
|
||||
p = gf.createPolygon(lr, null);
|
||||
isPolygonValid = p.isValid();
|
||||
if (isPolygonValid)
|
||||
break outerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private double calculateDistance(Coordinate c1, Coordinate c2) {
|
||||
return Math.sqrt(Math.pow(c1.x - c2.x, 2) + Math.pow(c1.y - c2.y, 2));
|
||||
}
|
||||
|
||||
public double computeSlope(Coordinate[] coords, int i, int j) {
|
||||
double min = 1.0E-08;
|
||||
double dx = coords[i].x - coords[j].x;
|
||||
double slope = 0.0;
|
||||
if (Math.abs(dx) > min) {
|
||||
slope = (coords[i].y - coords[j].y) / dx;
|
||||
}
|
||||
return slope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some counties/forecast zones have two GIDs, one is for the large portion
|
||||
* of that county and the other is for the small portion, e.g., inlets of a
|
||||
|
|
|
@ -931,7 +931,7 @@
|
|||
<Outlook outlookType="FIREOUTL" name="Outlook" pgenCategory="Outlook" pgenType="FIREOUTL">
|
||||
<DECollection collectionName="OutlookLine">
|
||||
<DrawableElement>
|
||||
<Line pgenType="POINTED_ARROW" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="false" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Line pgenType="POINTED_ARROW" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="true" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Color red="255" green="0" blue="0" alpha="255"/>
|
||||
<Color red="255" green="0" blue="0" alpha="255"/>
|
||||
<Point Lat="53.27859852972902" Lon="-77.19176906414972"/>
|
||||
|
@ -947,7 +947,7 @@
|
|||
</DECollection>
|
||||
<DECollection collectionName="OutlookLine">
|
||||
<DrawableElement>
|
||||
<Line pgenType="POINTED_ARROW" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="false" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Line pgenType="POINTED_ARROW" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="true" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Color red="255" green="0" blue="0" alpha="255"/>
|
||||
<Color red="255" green="0" blue="0" alpha="255"/>
|
||||
<Point Lat="52.0548811011688" Lon="-78.51595857033493"/>
|
||||
|
@ -963,7 +963,7 @@
|
|||
</DECollection>
|
||||
<DECollection collectionName="OutlookLine">
|
||||
<DrawableElement>
|
||||
<Line pgenType="SCALLOPED" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="false" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Line pgenType="SCALLOPED" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="true" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Color red="255" green="0" blue="0" alpha="255"/>
|
||||
<Color red="255" green="0" blue="0" alpha="255"/>
|
||||
<Point Lat="51.09332708822423" Lon="-79.79310615023532"/>
|
||||
|
@ -979,7 +979,7 @@
|
|||
</DECollection>
|
||||
<DECollection collectionName="OutlookLine">
|
||||
<DrawableElement>
|
||||
<Line pgenType="SCALLOPED" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="false" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Line pgenType="SCALLOPED" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="true" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Color red="139" green="71" blue="38" alpha="255"/>
|
||||
<Color red="139" green="71" blue="38" alpha="255"/>
|
||||
<Point Lat="50.61429836902503" Lon="-80.45991316913586"/>
|
||||
|
@ -995,7 +995,7 @@
|
|||
</DECollection>
|
||||
<DECollection collectionName="OutlookLine">
|
||||
<DrawableElement>
|
||||
<Line pgenType="SCALLOPED" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="false" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Line pgenType="SCALLOPED" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="true" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Color red="255" green="0" blue="0" alpha="255"/>
|
||||
<Color red="255" green="0" blue="0" alpha="255"/>
|
||||
<Point Lat="49.58615974295143" Lon="-81.22522929088485"/>
|
||||
|
@ -1011,7 +1011,7 @@
|
|||
</DECollection>
|
||||
<DECollection pgenCategory="MET" collectionName="OutlookLine">
|
||||
<DrawableElement>
|
||||
<Line pgenType="POINTED_ARROW" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="false" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Line pgenType="POINTED_ARROW" pgenCategory="Lines" lineWidth="2.0" sizeScale="1.0" smoothFactor="0" closed="true" filled="false" fillPattern="SOLID" flipSide="false">
|
||||
<Color red="139" green="71" blue="38" alpha="255"/>
|
||||
<Color red="139" green="71" blue="38" alpha="255"/>
|
||||
<Point Lat="54.76159387097988" Lon="-76.00927434860081"/>
|
||||
|
|
|
@ -3283,6 +3283,14 @@
|
|||
<parameter id="layerIndex" value="20" />
|
||||
</key>
|
||||
<!-- Hot keys to cut, copy paste PGEN elements -->
|
||||
<!-- DEL and Ctrl+X are same -->
|
||||
<key
|
||||
commandId="gov.noaa.nws.ncep.ui.pgen.tools.PgenCopypasteHotkeyCommand"
|
||||
contextId="gov.noaa.nws.ncep.ui.pgen.pgenContext"
|
||||
schemeId="com.raytheon.viz.ui.awips.scheme"
|
||||
sequence="DEL">
|
||||
<parameter id="action" value="CUT" />
|
||||
</key>
|
||||
<key
|
||||
commandId="gov.noaa.nws.ncep.ui.pgen.tools.PgenCopypasteHotkeyCommand"
|
||||
contextId="gov.noaa.nws.ncep.ui.pgen.pgenContext"
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
package gov.noaa.nws.ncep.ui.pgen.tools;
|
||||
|
||||
import gov.noaa.nws.ncep.ui.pgen.PgenSession;
|
||||
import gov.noaa.nws.ncep.ui.pgen.PgenUtil;
|
||||
import gov.noaa.nws.ncep.ui.pgen.attrdialog.AttrDlg;
|
||||
import gov.noaa.nws.ncep.ui.pgen.attrdialog.AttrDlgFactory;
|
||||
|
@ -57,7 +56,6 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.geotools.referencing.GeodeticCalculator;
|
||||
|
||||
|
@ -74,6 +72,7 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 04/13 #927 B. Yin Moved from the PgenSelectingTool class
|
||||
* 05/13 #994 J. Wu Removed "DEL" - make it same as "Ctrl+X"
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -875,7 +874,7 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean handleKeyDown(int keyCode) {
|
||||
if ( !tool.isResourceEditable() ) return false;
|
||||
|
||||
|
@ -888,7 +887,7 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
else super.handleKeyDown(keyCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
private void setGhostLineColorForTrack(MultiPointElement multiPointElement, int nearestPointIndex) {
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
<mapping key="pluginName">
|
||||
<constraint constraintValue="${pluginName}" constraintType="EQUALS" />
|
||||
</mapping>
|
||||
<!-- Uncomment this when the baseline is updated for lightSource
|
||||
<mapping key="lightSource">
|
||||
<constraint constraintValue="${lightSource}" constraintType="IN" />
|
||||
</mapping>
|
||||
-->
|
||||
</metadataMap>
|
||||
</resourceData>
|
||||
</resource>
|
||||
|
|
|
@ -80,6 +80,16 @@
|
|||
paramType="IMPLEMENTATION_PARAM">
|
||||
</nc-resourceParameter>
|
||||
|
||||
<!-- Change this to a REQUEST_CONSTRAINT when our baseline is updated to get
|
||||
the latest binlightning decoder implementing the lightSource column -->
|
||||
<nc-resourceParameter
|
||||
ncResourceName="Lightning"
|
||||
paramClass="String"
|
||||
paramName="lightSource"
|
||||
defaultValue="NLDN"
|
||||
paramType="IMPLEMENTATION_PARAM">
|
||||
</nc-resourceParameter>
|
||||
|
||||
<nc-resourceParameter
|
||||
ncResourceName="Lightning"
|
||||
paramClass="RGB"
|
||||
|
|
|
@ -63,7 +63,8 @@ import com.raytheon.uf.viz.core.rsc.ResourceType;
|
|||
* show strike count in legend
|
||||
* 02/16/2012 #555 S. Gurung Added call to setAllFramesAsPopulated() in queryRecords()
|
||||
* 05/23/12 785 Q. Zhou Added getName for legend.
|
||||
* 12/19/2012 #960 Greg Hull override propertiesChanged() to update colorBar.
|
||||
* 12/19/2012 #960 Greg Hull override propertiesChanged() to update colorBar.
|
||||
* 05/07/2013 #993 Greg Hull change key for strikeMap from URI to the HDF5 group
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -341,49 +342,47 @@ public class LightningResource extends AbstractNatlCntrsResource<LightningResour
|
|||
|
||||
// loop thru the URIs and find the hdf5 lat,lon and intensity records for this
|
||||
// URI and then fill in the strikeMap with all of the strikes for this URI.
|
||||
for( String uri : uris ) {
|
||||
for( IDataRecord hdf5Rec : hdf5Recs ) {
|
||||
if( hdf5Rec.getGroup().equals( uri ) ) {
|
||||
List<LtngStrikeDataObj> strikeList = strikeMap.get(uri);
|
||||
for( IDataRecord hdf5Rec : hdf5Recs ) {
|
||||
String grp = hdf5Rec.getGroup(); //.replaceAll("::", "/" );
|
||||
|
||||
List<LtngStrikeDataObj> strikeList = strikeMap.get(grp);
|
||||
|
||||
if( strikeList == null ) {
|
||||
strikeList = new ArrayList<LtngStrikeDataObj>();
|
||||
strikeMap.put(uri, strikeList);
|
||||
|
||||
// init with the number of strikes for this record.
|
||||
// NOTE: all of the records for this uri must(will) have the same
|
||||
// number of strikes in them.
|
||||
for( int s=0 ; s<hdf5Rec.getSizes()[0] ; s++ ) {
|
||||
strikeList.add( new LtngStrikeDataObj() );
|
||||
|
||||
strikeCount++;
|
||||
}
|
||||
}
|
||||
if( hdf5Rec.getSizes()[0] != strikeList.size() ) {
|
||||
System.out.println("HDF5 Warning: ");
|
||||
}
|
||||
|
||||
for( int s=0 ; s<hdf5Rec.getSizes()[0] ; s++ ) {
|
||||
LtngStrikeDataObj strikeInfo = strikeList.get(s);
|
||||
if( hdf5Rec.getName().equals("intensity") ) {
|
||||
strikeInfo.intensity = ((IntegerDataRecord) hdf5Rec).getIntData()[s];
|
||||
} else if( hdf5Rec.getName().equals("latitude") ) {
|
||||
strikeInfo.lat = ((FloatDataRecord) hdf5Rec).getFloatData()[s];
|
||||
} else if( hdf5Rec.getName().equals("longitude") ) {
|
||||
strikeInfo.lon = ((FloatDataRecord) hdf5Rec).getFloatData()[s];
|
||||
} else if( hdf5Rec.getName().equals("obsTime") ) {
|
||||
strikeInfo.strikeTime = ((LongDataRecord) hdf5Rec).getLongData()[s];
|
||||
if( strikeList == null ) {
|
||||
strikeList = new ArrayList<LtngStrikeDataObj>();
|
||||
strikeMap.put(grp, strikeList);
|
||||
|
||||
// init with the number of strikes for this record.
|
||||
// NOTE: all of the records for this uri must(will) have the same
|
||||
// number of strikes in them.
|
||||
for( int s=0 ; s<hdf5Rec.getSizes()[0] ; s++ ) {
|
||||
strikeList.add( new LtngStrikeDataObj() );
|
||||
|
||||
strikeCount++;
|
||||
}
|
||||
}
|
||||
if( hdf5Rec.getSizes()[0] != strikeList.size() ) {
|
||||
System.out.println("HDF5 Warning: ");
|
||||
}
|
||||
|
||||
for( int s=0 ; s<hdf5Rec.getSizes()[0] ; s++ ) {
|
||||
LtngStrikeDataObj strikeInfo = strikeList.get(s);
|
||||
if( hdf5Rec.getName().equals("intensity") ) {
|
||||
strikeInfo.intensity = ((IntegerDataRecord) hdf5Rec).getIntData()[s];
|
||||
} else if( hdf5Rec.getName().equals("latitude") ) {
|
||||
strikeInfo.lat = ((FloatDataRecord) hdf5Rec).getFloatData()[s];
|
||||
} else if( hdf5Rec.getName().equals("longitude") ) {
|
||||
strikeInfo.lon = ((FloatDataRecord) hdf5Rec).getFloatData()[s];
|
||||
} else if( hdf5Rec.getName().equals("obsTime") ) {
|
||||
strikeInfo.strikeTime = ((LongDataRecord) hdf5Rec).getLongData()[s];
|
||||
// if( strikeInfo.obsTime > latestStrike ) {
|
||||
// latestStrike = strikeInfo.obsTime;
|
||||
// }
|
||||
// } else if( hdf5Rec.getName().equals("strikeCount") ) {
|
||||
// strikeInfo.lon = ((FloatDataRecord) hdf5Rec).getFloatData()[s];
|
||||
} else if( hdf5Rec.getName().equals("msgType") ) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if( hdf5Rec.getName().equals("msgType") ) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (StorageException e) {
|
||||
|
@ -404,8 +403,8 @@ public class LightningResource extends AbstractNatlCntrsResource<LightningResour
|
|||
|
||||
// return a list of all the strikes for all the uris.
|
||||
ArrayList<LtngStrikeDataObj> strikeList = new ArrayList<LtngStrikeDataObj>();
|
||||
for( String uri : strikeMap.keySet() ) {
|
||||
strikeList.addAll( strikeMap.get( uri ) );
|
||||
for( String hdfgrp : strikeMap.keySet() ) {
|
||||
strikeList.addAll( strikeMap.get( hdfgrp ) );
|
||||
}
|
||||
|
||||
return strikeList;
|
||||
|
|
|
@ -41,8 +41,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.locks.*;
|
||||
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
|
@ -63,7 +61,7 @@ import com.raytheon.edex.meteoLib.Controller;
|
|||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.CRSCache;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.geospatial.util.WorldWrapCorrector;
|
||||
import com.raytheon.uf.common.geospatial.util.WorldWrapChecker;
|
||||
import com.raytheon.uf.common.util.ArraysUtil;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
|
@ -111,6 +109,8 @@ import com.vividsolutions.jts.linearref.LocationIndexedLine;
|
|||
* Mar 27, 2012 X. Guo Used contour lock instead of "synchronized"
|
||||
* May 23, 2012 X. Guo Loaded ncgrib logger
|
||||
* Apr 26, 2013 B. Yin Fixed the world wrap problem for centeral line 0/180.
|
||||
* Jun 06, 2013 B. Yin fixed the half-degree grid porblem.
|
||||
* Jul 19, 2013 B. Hebbard Merge in RTS change of Util-->ArraysUtil
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -145,10 +145,31 @@ public class ContourSupport {
|
|||
private List<Double> cvalues;
|
||||
private List<Double> fvalues;
|
||||
private Set<Double> svalues;
|
||||
private boolean isWorld0;
|
||||
private boolean globalData = false;
|
||||
|
||||
//world map with central meridian at 180 degree
|
||||
private boolean isWorld180;
|
||||
|
||||
//return value from raytheon's worlWrapChecker
|
||||
private boolean worldWrapChecker;
|
||||
|
||||
//flag that indicates world wrap is needed
|
||||
private boolean worldWrap;
|
||||
|
||||
//central meridian
|
||||
private double centralMeridian = 0;
|
||||
|
||||
//screen width of the map
|
||||
private double mapScreenWidth;
|
||||
|
||||
//screen x of the zero longitude
|
||||
private double zeroLonOnScreen;
|
||||
|
||||
//maximum number of grid along x direction
|
||||
private int maxGridX;
|
||||
|
||||
private boolean isCntrsCreated;
|
||||
private static NcgribLogger ncgribLogger = NcgribLogger.getInstance();;
|
||||
private static NcgribLogger ncgribLogger = NcgribLogger.getInstance();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -293,9 +314,13 @@ public class ContourSupport {
|
|||
this.name = name;
|
||||
this.zoom = zoom;
|
||||
this.cntrData = new ContourGridData(records);
|
||||
this.isWorld0 = (getCentralMeridian(descriptor) == 0.0);
|
||||
this.isWorld180 = (Math.abs(getCentralMeridian(descriptor)) == 180.0);
|
||||
|
||||
this.centralMeridian = getCentralMeridian(descriptor);
|
||||
if ( centralMeridian == -180 ) centralMeridian = 180;
|
||||
this.isWorld180 = (centralMeridian == 180.0);
|
||||
this.worldWrapChecker = new WorldWrapChecker(descriptor.getGridGeometry().getEnvelope()).needsChecking();
|
||||
this.worldWrap = needWrap(imageGridGeometry, rastPosToLatLon);
|
||||
mapScreenWidth = this.getMapWidth();
|
||||
maxGridX = this.getMaxGridX(imageGridGeometry);
|
||||
initContourGroup ( target,contourGp );
|
||||
}
|
||||
/**
|
||||
|
@ -448,89 +473,6 @@ public class ContourSupport {
|
|||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Create labels for a linestring
|
||||
*
|
||||
* @param contourGroup
|
||||
* @param levelOffset
|
||||
* @param contourValue
|
||||
* @param labelPoints
|
||||
* @param valsArr
|
||||
*/
|
||||
private static void prepareLabel(ContourGroup contourGroup,
|
||||
double screenToPixel, float contourValue,
|
||||
List<double[]> labelPoints, double[][] valsArr) {
|
||||
|
||||
double[] lastPoint = new double[] { Double.POSITIVE_INFINITY,
|
||||
Double.POSITIVE_INFINITY };
|
||||
|
||||
double d = 0.0;
|
||||
|
||||
final double threshold1 = (200.0 / screenToPixel);
|
||||
final double threshold2 = (100.0 / screenToPixel);
|
||||
|
||||
long tAccum = 0;
|
||||
double q1, q2, p1, p2;
|
||||
DecimalFormat df = new DecimalFormat("0.#");
|
||||
for (int n = 0; n < valsArr.length; n++) {
|
||||
|
||||
// Distance approximation between last label point
|
||||
// and current point
|
||||
|
||||
// Absolute value logic inlined for performance
|
||||
q1 = lastPoint[0] - valsArr[n][0];
|
||||
q2 = lastPoint[1] - valsArr[n][1];
|
||||
q1 = (q1 <= 0.0D) ? 0.0D - q1 : q1;
|
||||
q2 = (q2 <= 0.0D) ? 0.0D - q2 : q2;
|
||||
|
||||
d = q1 + q2;
|
||||
|
||||
// If distance has been enough, add a label
|
||||
if (d > (threshold1)
|
||||
/* || (labeledAtLeastOnce == false && n == valsArr.length - 1) */) {
|
||||
// Search for any labels that are too close
|
||||
// to the current one
|
||||
boolean tooClose = false;
|
||||
p1 = valsArr[n][0];
|
||||
p2 = valsArr[n][1];
|
||||
|
||||
q1 = 0;
|
||||
q2 = 0;
|
||||
for (double[] test : labelPoints) {
|
||||
// Distance approximation between each label
|
||||
// point and current point
|
||||
// Absolute value logic inlined for performance
|
||||
q1 = test[0] - p1;
|
||||
q2 = test[1] - p2;
|
||||
q1 = (q1 <= 0.0D) ? -1.0D * q1 : q1;
|
||||
q2 = (q2 <= 0.0D) ? -1.0D * q2 : q2;
|
||||
d = q1 + q2;
|
||||
if (d < threshold2) {
|
||||
tooClose = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!tooClose
|
||||
/* || (labeledAtLeastOnce == false && n == valsArr.length - 1) */) {
|
||||
long t0 = System.currentTimeMillis();
|
||||
// if (contourValue >= 0) {
|
||||
// contourGroup.posValueShape.addLabel(df
|
||||
// .format(contourValue), valsArr[n]);
|
||||
// } else {
|
||||
contourGroup.negValueShape.addLabel(df
|
||||
.format(contourValue), valsArr[n]);
|
||||
// }
|
||||
|
||||
labelPoints.add(valsArr[n]);
|
||||
lastPoint = valsArr[n];
|
||||
tAccum += (System.currentTimeMillis() - t0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private double[][] toScreen(Coordinate[] coords, MathTransform xform, int minX, int minY) {
|
||||
|
||||
int size = coords.length;
|
||||
|
@ -538,14 +480,15 @@ public class ContourSupport {
|
|||
//remove points on longitude 360 degree. to avoid long cross lines
|
||||
if ( isWorld180 ) {
|
||||
for ( Coordinate pt : coords ){
|
||||
if ( pt.x == 360.0) size--;
|
||||
if ( pt.x == maxGridX) size--;
|
||||
}
|
||||
}
|
||||
|
||||
double[][] out = new double[size][3];
|
||||
|
||||
long nx = records.getSizes()[0] - 1;
|
||||
|
||||
for ( int i=0, jj = 0; i< coords.length; i++, jj++ ) {
|
||||
if ( isWorld180 && coords[i].x == 360.0 ){ jj--; continue;}
|
||||
if ( isWorld180 && coords[i].x == maxGridX ){ jj--; continue;}
|
||||
|
||||
double[] tmp = new double[2];
|
||||
tmp[0]=coords[i].x + minX;
|
||||
|
@ -559,59 +502,173 @@ public class ContourSupport {
|
|||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( worldWrapChecker ) {
|
||||
if ( tmp[0] > (nx-1) && out[jj][0] < 0){
|
||||
out[jj][0] = mapScreenWidth;
|
||||
}
|
||||
else if (tmp[0] < 1 && out[jj][0] > mapScreenWidth*0.9 ){
|
||||
out[jj][0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( out.length > 0 ) {
|
||||
return out;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static double[][] toScreenSubtract360(Coordinate[] coords, MathTransform xform,MathTransform xform1, int minX, int minY) {
|
||||
// Coordinate[] out = new Coordinate[coords.length];
|
||||
private double[][] toScreenRightOfZero(Coordinate[] coords, MathTransform xform, int minX, int minY) {
|
||||
// Coordinate[] out = new Coordinate[coords.length];
|
||||
double[][] out = new double[coords.length][3];
|
||||
double[] tmpout = new double[3];
|
||||
|
||||
for ( int i=0; i< coords.length; i++ ) {
|
||||
double[] tmp = new double[2];
|
||||
tmp[0]=coords[i].x + minX;
|
||||
tmp[1]=coords[i].y + minY;
|
||||
// if (tmp[0] > 180.0) tmp[0] -= 360.0;
|
||||
|
||||
try {
|
||||
xform.transform(tmp, 0, tmpout, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
tmpout[0] -= 360.0;
|
||||
try {
|
||||
xform1.transform(tmpout, 0, out[i], 0, 1);
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if ( out.length > 0 ) {
|
||||
return out;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
for ( int i=0; i< coords.length; i++ ) {
|
||||
double[] tmp = new double[2];
|
||||
tmp[0]=coords[i].x + minX;
|
||||
tmp[1]=coords[i].y + minY;
|
||||
|
||||
try {
|
||||
xform.transform(tmp, 0, out[i], 0, 1);
|
||||
} catch (TransformException e) {
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
// System.out.println("WWWWWWW " + tmp[0]+" " + " " + out[i][0]);
|
||||
|
||||
if ( out[i][0] < zeroLonOnScreen || (tmp[0] == maxGridX && out[i][0] == zeroLonOnScreen)){
|
||||
out[i][0] += mapScreenWidth;
|
||||
// System.out.println("Shift " + tmp[0]+" " + out[i][0]);
|
||||
}
|
||||
// else if ( delta < 0 && !(out[i][0] < middle ) && (delta < 0 || Math.abs(out[i][0]) < Math.abs(delta)) ){
|
||||
|
||||
// System.out.println("SSSSSSSSSSSShift" + tmp[0]+" " + tmpout[0] + " " + out[i][0]);
|
||||
// out[i][0] += delta;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
if ( out.length > 0 ) {
|
||||
return out;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private LineString toScreenLSRightOfZero(Coordinate[] coords, MathTransform xform, int minX, int minY) {
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
Coordinate[] out = new Coordinate[coords.length];
|
||||
double[] tmpout = new double[3];
|
||||
|
||||
for ( int i=0; i< coords.length; i++ ) {
|
||||
double[] tmp = new double[2];
|
||||
tmp[0]=coords[i].x + minX;
|
||||
tmp[1]=coords[i].y + minY;
|
||||
|
||||
try {
|
||||
xform.transform(tmp, 0, tmpout, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( tmpout[0] < zeroLonOnScreen || (tmp[0] == maxGridX && tmpout[0] == zeroLonOnScreen)){
|
||||
tmpout[0] += mapScreenWidth;
|
||||
}
|
||||
|
||||
out[i] = new Coordinate( tmpout[0], tmpout[1] );
|
||||
|
||||
}
|
||||
|
||||
if ( out.length >= 2 ) {
|
||||
return gf.createLineString(out);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private double[][] toScreenLeftOfZero(Coordinate[] coords, MathTransform xform, int minX, int minY) {
|
||||
// Coordinate[] out = new Coordinate[coords.length];
|
||||
double[][] out = new double[coords.length][3];
|
||||
|
||||
for ( int i=0; i< coords.length; i++ ) {
|
||||
double[] tmp = new double[2];
|
||||
tmp[0]=coords[i].x + minX;
|
||||
tmp[1]=coords[i].y + minY;
|
||||
|
||||
try {
|
||||
xform.transform(tmp, 0, out[i], 0, 1);
|
||||
} catch (TransformException e) {
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
// System.out.println("WWWWWWW " + tmp[0]+" " + tmpout[0] + " " + out[i][0]);
|
||||
|
||||
if ( out[i][0] > zeroLonOnScreen || ( tmp[0] == 0 && out[i][0] == zeroLonOnScreen )){
|
||||
// System.out.println("Shift " + tmp[0]+" " + out[i][0]);
|
||||
out[i][0] -= mapScreenWidth;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( out.length > 0 ) {
|
||||
return out;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private LineString toScreenLSLeftOfZero(Coordinate[] coords, MathTransform xform, int minX, int minY) {
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
Coordinate[] out = new Coordinate[coords.length];
|
||||
double[] tmpout = new double[3];
|
||||
|
||||
for ( int i=0; i< coords.length; i++ ) {
|
||||
double[] tmp = new double[2];
|
||||
tmp[0]=coords[i].x + minX;
|
||||
tmp[1]=coords[i].y + minY;
|
||||
|
||||
try {
|
||||
xform.transform(tmp, 0, tmpout, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( tmpout[0] > zeroLonOnScreen || (tmp[0] == 0 && tmpout[0] == zeroLonOnScreen)){
|
||||
tmpout[0] -= mapScreenWidth;
|
||||
}
|
||||
|
||||
out[i] = new Coordinate( tmpout[0], tmpout[1] );
|
||||
|
||||
}
|
||||
|
||||
if ( out.length >= 2 ) {
|
||||
return gf.createLineString(out);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private LineString toScreenLS(Coordinate[] coords, MathTransform xform, int minX, int minY) {
|
||||
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
long nx = records.getSizes()[0] - 1;
|
||||
|
||||
int size = coords.length;
|
||||
//remove points on 360. to avoid long cross lines
|
||||
if ( isWorld180 ) {
|
||||
for ( Coordinate pt : coords ){
|
||||
if ( pt.x == 360.0) size--;
|
||||
if ( pt.x == maxGridX) size--;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -619,7 +676,7 @@ public class ContourSupport {
|
|||
double[] tmpout = new double[3];
|
||||
|
||||
for ( int i=0, jj = 0; i< coords.length; i++, jj++ ) {
|
||||
if ( isWorld180 && coords[i].x == 360.0 ){ jj--; continue;}
|
||||
if ( isWorld180 && coords[i].x == maxGridX ){ jj--; continue;}
|
||||
|
||||
double[] tmp = new double[2];
|
||||
tmp[0]=coords[i].x + minX;
|
||||
|
@ -633,50 +690,27 @@ public class ContourSupport {
|
|||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
if ( worldWrapChecker ) {
|
||||
if ( tmp[0] > (nx-1) && tmpout[0] < 0){
|
||||
tmpout[0] = extent.getMaxX();
|
||||
}
|
||||
else if (tmp[0] < 1 && tmpout[0] > extent.getMaxX()*0.9 ){
|
||||
tmpout[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out[jj] = new Coordinate( tmpout[0], tmpout[1] );
|
||||
}
|
||||
|
||||
if ( out.length >= 2 ) {
|
||||
return gf.createLineString(out);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static LineString toScreenLSSubtract360(Coordinate[] coords, MathTransform xform, MathTransform xform1,int minX, int minY) {
|
||||
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
Coordinate[] out = new Coordinate[coords.length];
|
||||
double[] tmpout = new double[3];
|
||||
double[] tmpout1 = new double[3];
|
||||
|
||||
for ( int i=0; i< coords.length; i++ ) {
|
||||
double[] tmp = new double[2];
|
||||
tmp[0]=coords[i].x + minX;
|
||||
tmp[1]=coords[i].y + minY;
|
||||
// if (tmp[0] > 180) tmp[0] -= 360;
|
||||
|
||||
try {
|
||||
xform.transform(tmp, 0, tmpout, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
tmpout[0] -= 360.0;
|
||||
try {
|
||||
xform1.transform(tmpout, 0, tmpout1, 0, 1);
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
out[i] = new Coordinate( tmpout1[0], tmpout1[1] );
|
||||
}
|
||||
|
||||
return gf.createLineString(out);
|
||||
}
|
||||
|
||||
private static Geometry polyToLine(Polygon poly) {
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
|
||||
|
@ -772,6 +806,7 @@ public class ContourSupport {
|
|||
double centralMeridian = group.parameter(
|
||||
AbstractProvider.CENTRAL_MERIDIAN.getName().getCode())
|
||||
.doubleValue();
|
||||
if ( centralMeridian > 180 ) centralMeridian -= 360;
|
||||
return centralMeridian;
|
||||
}
|
||||
return -999;
|
||||
|
@ -969,7 +1004,10 @@ public class ContourSupport {
|
|||
|
||||
|
||||
int n = 0,minX=0,minY=0;
|
||||
|
||||
|
||||
double[][] screen = null;
|
||||
double[][] screenx = null;
|
||||
|
||||
for ( Double cval : contourGroup.cvalues ) {
|
||||
float fval = (float) (cval * 1.0f);
|
||||
boolean toLabel = false;
|
||||
|
@ -991,66 +1029,41 @@ public class ContourSupport {
|
|||
}
|
||||
|
||||
|
||||
// Geometry g = cgen.getContours(fval);
|
||||
Geometry g = contourGroup.data.get(cval.toString());
|
||||
if ( g == null ) continue;
|
||||
// contourMap.put( cval, g);
|
||||
|
||||
/* Geometry gclone = (Geometry)g.clone();
|
||||
|
||||
for ( Coordinate pt : gclone.getCoordinates() ){
|
||||
if ( pt.x > 180 ) pt.x -=360;
|
||||
if ( pt.y > 90 ) pt.y = pt.y*-1 + 90; // ????????
|
||||
}
|
||||
|
||||
WorldWrapCorrector corrector = new WorldWrapCorrector(
|
||||
descriptor.getGridGeometry());
|
||||
|
||||
Geometry geo = null;
|
||||
try {
|
||||
geo = corrector.correct( gclone );
|
||||
}
|
||||
catch ( Exception e ){
|
||||
System.out.println( "World wrap error: " + e.getMessage() );
|
||||
}
|
||||
*/
|
||||
// if ( geo != null ) g =geo;
|
||||
|
||||
double[][] screen1 = null;
|
||||
for ( int i=0; i < g.getNumGeometries(); i++ ) {
|
||||
Geometry gn = g.getGeometryN(i);
|
||||
|
||||
// System.out.println( "First pt : " + gn.getCoordinates()[0].x + " " + gn.getCoordinates()[0].y);
|
||||
// System.out.println( "Last pt : " + gn.getCoordinates()[gn.getCoordinates().length-1].x + " " + gn.getCoordinates()[gn.getCoordinates().length-1].y);
|
||||
if ( worldWrap ) {
|
||||
// screen = toScreenRightPart( gn.getCoordinates(), 0, rastPosToLatLon,rastPosLatLonToWorldGrid, minX, minY );
|
||||
// if ( screen != null ) contourGroup.negValueShape.addLineSegment(screen);
|
||||
|
||||
screen = toScreenRightOfZero( gn.getCoordinates(), rastPosToWorldGrid, minX, minY );
|
||||
if ( screen != null ) contourGroup.negValueShape.addLineSegment(screen);
|
||||
|
||||
screenx = toScreenLeftOfZero( gn.getCoordinates(), rastPosToWorldGrid, minX, minY );
|
||||
if ( screenx != null ) contourGroup.negValueShape.addLineSegment(screenx);
|
||||
}
|
||||
else {
|
||||
screen = toScreen( gn.getCoordinates(), rastPosToWorldGrid, minX, minY );
|
||||
if ( screen != null ) contourGroup.negValueShape.addLineSegment(screen);
|
||||
}
|
||||
|
||||
//toLabel = false;
|
||||
// double[][] pixels = PgenUtil.latlonToPixel( gn.getCoordinates(), descriptor);
|
||||
//contourGroup.negValueShape.addLineSegment(pixels);
|
||||
|
||||
/* for ( Coordinate pt : gn.getCoordinates() ){
|
||||
if ( pt.x < 0 ) pt.x +=360;
|
||||
if ( pt.y < 90 ) pt.y = pt.y*-1 + 90; // ????????
|
||||
System.out.println( "PPPPPPPPPPPPPPPPP: " + pt.x + " " + pt.y);
|
||||
}
|
||||
*/
|
||||
double[][] screen = toScreen( gn.getCoordinates(), rastPosToWorldGrid, minX, minY );
|
||||
|
||||
if ( screen != null )
|
||||
contourGroup.negValueShape.addLineSegment(screen);
|
||||
if ( isWorld0 ) {
|
||||
/* if ( isWorld0 ) {
|
||||
screen1 = toScreenSubtract360( gn.getCoordinates(), rastPosToLatLon,rastPosLatLonToWorldGrid, minX, minY );
|
||||
if ( screen1 != null )
|
||||
contourGroup.negValueShape.addLineSegment(screen1);
|
||||
}
|
||||
|
||||
*/
|
||||
if (toLabel) {
|
||||
long tl0 = System.currentTimeMillis();
|
||||
// prepareLabel(contourGroup, zoom, fval,
|
||||
// labelPoints, screen);
|
||||
if ( screen != null )
|
||||
createContourLabel(extent, contourGroup, fval, screen);
|
||||
if ( isWorld0 && screen1 != null) {
|
||||
createContourLabel(extent, contourGroup, fval, screen1);
|
||||
if ( screenx != null) {
|
||||
createContourLabel(extent, contourGroup, fval, screenx);
|
||||
}
|
||||
long tl1 = System.currentTimeMillis();
|
||||
total_labeling_time += (tl1-tl0);
|
||||
|
@ -1132,14 +1145,27 @@ public class ContourSupport {
|
|||
for (int j=0; j<fillPolys.getNumGeometries(); j++ ) {
|
||||
Geometry g = fillPolys.getGeometryN(j);
|
||||
if ( g instanceof Polygon ) g = polyToLine( (Polygon)g );
|
||||
LineString ls = toScreenLS( g.getCoordinates(), rastPosToWorldGrid, minX, minY);
|
||||
if ( ls != null )
|
||||
contourGroup.fillShapes.addPolygonPixelSpace(new LineString[]{ls}, color);
|
||||
if ( isWorld0 ) {
|
||||
ls = toScreenLSSubtract360( g.getCoordinates(), rastPosToLatLon,rastPosLatLonToWorldGrid, minX, minY);
|
||||
|
||||
if ( worldWrap ){
|
||||
LineString ls = toScreenLSRightOfZero( g.getCoordinates(), rastPosToWorldGrid, minX, minY);
|
||||
if ( ls != null )
|
||||
contourGroup.fillShapes.addPolygonPixelSpace(new LineString[]{ls}, color);
|
||||
ls = toScreenLSLeftOfZero( g.getCoordinates(), rastPosToWorldGrid, minX, minY);
|
||||
if ( ls != null )
|
||||
contourGroup.fillShapes.addPolygonPixelSpace(new LineString[]{ls}, color);
|
||||
}
|
||||
else {
|
||||
LineString ls = toScreenLS( g.getCoordinates(), rastPosToWorldGrid, minX, minY);
|
||||
if ( ls != null )
|
||||
contourGroup.fillShapes.addPolygonPixelSpace(new LineString[]{ls}, color);
|
||||
}
|
||||
|
||||
|
||||
// if ( isWorld0 ) {
|
||||
// ls = toScreenLSSubtract360( g.getCoordinates(), rastPosToLatLon,rastPosLatLonToWorldGrid, minX, minY);
|
||||
// if ( ls != null )
|
||||
// contourGroup.fillShapes.addPolygonPixelSpace(new LineString[]{ls}, color);
|
||||
// }
|
||||
}
|
||||
} catch (FillException e) {
|
||||
// e.printStackTrace();
|
||||
|
@ -1167,36 +1193,61 @@ public class ContourSupport {
|
|||
float[] vW = null;
|
||||
long[] sz = records.getSizes();
|
||||
|
||||
uW = ((NcFloatDataRecord) records).getXdata();
|
||||
vW = ((NcFloatDataRecord) records).getYdata();
|
||||
|
||||
// Step 2: Determine the subgrid, if any
|
||||
int minX=0,minY=0;
|
||||
int maxX = (int)sz[0] - 1;
|
||||
int maxY = (int)sz[1] - 1;
|
||||
int szX = (maxX - minX) + 1;
|
||||
int szY = (maxY - minY) + 1;
|
||||
int x = (int) sz[0];
|
||||
|
||||
uW = ((NcFloatDataRecord) records).getXdata();
|
||||
vW = ((NcFloatDataRecord) records).getYdata();
|
||||
|
||||
if ( globalData ){ // remove column 360
|
||||
x--;
|
||||
szX--;
|
||||
maxX--;
|
||||
}
|
||||
|
||||
int totalSz = szX * szY;
|
||||
if (totalSz <= 0) {
|
||||
isCntrsCreated = false;
|
||||
return ;
|
||||
}
|
||||
int x = (int) sz[0];
|
||||
|
||||
float[] adjustedUw = new float[totalSz];
|
||||
float[] adjustedVw = new float[totalSz];
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (int j = 0; j < szY; j++) {
|
||||
for (int i = 0; i < szX; i++) {
|
||||
if ( globalData ){
|
||||
for (int j = 0; j < szY; j++) {
|
||||
for (int i = 0; i < szX+1; i++) {
|
||||
if (( i+minX )== 360 ) {
|
||||
continue;
|
||||
}
|
||||
adjustedUw[n] = uW[((x+1) * (j + minY)) + (i + minX)];
|
||||
adjustedVw[n] = vW[((x+1) * (j + minY)) + (i + minX)];
|
||||
|
||||
adjustedUw[n] = uW[(x * (j + minY)) + (i + minX)];
|
||||
adjustedVw[n] = vW[(x * (j + minY)) + (i + minX)];
|
||||
n++;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int j = 0; j < szY; j++) {
|
||||
for (int i = 0; i < szX; i++) {
|
||||
adjustedUw[n] = uW[(x * (j + minY)) + (i + minX)];
|
||||
adjustedVw[n] = vW[(x * (j + minY)) + (i + minX)];
|
||||
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for ( int kk = 0; kk < 365; kk++ ){
|
||||
// System.out.println( kk + " " + adjustedUw[kk]+ " " + uW[kk]);
|
||||
// }
|
||||
|
||||
ArraysUtil.flipVert(adjustedUw, szY, szX);
|
||||
ArraysUtil.flipVert(adjustedVw, szY, szX);
|
||||
|
@ -1249,37 +1300,61 @@ public class ContourSupport {
|
|||
// System.out.println("Streamline Contouring took: " + (t1 - t0));
|
||||
|
||||
List<double[]> vals = new ArrayList<double[]>();
|
||||
List<Coordinate> pts = new ArrayList<Coordinate>();
|
||||
double[][] screen, screenx;;
|
||||
|
||||
long tAccum = 0;
|
||||
try {
|
||||
for (int i = 0; i < numPoints[0] && i < xPoints.length; i++) {
|
||||
if (xPoints[i] == -99999.0) {
|
||||
if (vals.size() > 0) {
|
||||
double[][] valsArr = vals.toArray(new double[vals
|
||||
.size()][2]);
|
||||
contourGroup.posValueShape.addLineSegment(valsArr);
|
||||
vals.clear();
|
||||
if (pts.size() > 0 ) {
|
||||
|
||||
if ( worldWrap ) {
|
||||
screen = toScreenRightOfZero( pts.toArray(new Coordinate[pts.size()]), rastPosToWorldGrid, minX, minY );
|
||||
if ( screen != null ) contourGroup.posValueShape.addLineSegment(screen);
|
||||
|
||||
screenx = toScreenLeftOfZero( pts.toArray(new Coordinate[pts.size()]),rastPosToWorldGrid, minX, minY );
|
||||
if ( screenx != null ) contourGroup.posValueShape.addLineSegment(screenx);
|
||||
}
|
||||
else {
|
||||
double[][] valsArr = vals.toArray(new double[vals.size()][2]);
|
||||
contourGroup.posValueShape.addLineSegment(valsArr);
|
||||
}
|
||||
|
||||
vals.clear();
|
||||
pts.clear();
|
||||
|
||||
}
|
||||
} else {
|
||||
double[] out = new double[2];
|
||||
try {
|
||||
long tZ0 = System.currentTimeMillis();
|
||||
|
||||
float f = maxX - xPoints[i];
|
||||
float f;
|
||||
|
||||
if ( xPoints[i] >= 360 ){
|
||||
f = 0;
|
||||
}
|
||||
|
||||
else {
|
||||
f= maxX + 1 - xPoints[i];
|
||||
}
|
||||
|
||||
if (f > 180) f = f - 360;
|
||||
|
||||
rastPosToWorldGrid.transform(new double[] {
|
||||
f, yPoints[i] + minY }, 0,
|
||||
out, 0, 1);
|
||||
|
||||
// rastPosToWorldGrid.transform(new double[] {
|
||||
// maxX - xPoints[i], yPoints[i] + minY }, 0,
|
||||
// out, 0, 1);
|
||||
pts.add( new Coordinate(f, yPoints[i] + minY));
|
||||
|
||||
long tZ1 = System.currentTimeMillis();
|
||||
tAccum += (tZ1 - tZ0);
|
||||
} catch (TransformException e) {
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
vals.add(out);
|
||||
}
|
||||
}
|
||||
|
@ -1291,6 +1366,14 @@ public class ContourSupport {
|
|||
double[][] valsArr = vals
|
||||
.toArray(new double[vals.size()][2]);
|
||||
contourGroup.posValueShape.addLineSegment(valsArr);
|
||||
|
||||
if ( worldWrap ) {
|
||||
screen = toScreenRightOfZero( pts.toArray(new Coordinate[pts.size()]), rastPosToWorldGrid, minX, minY );
|
||||
if ( screen != null ) contourGroup.posValueShape.addLineSegment(screen);
|
||||
|
||||
screenx = toScreenLeftOfZero( pts.toArray(new Coordinate[pts.size()]),rastPosToWorldGrid, minX, minY );
|
||||
if ( screenx != null ) contourGroup.posValueShape.addLineSegment(screenx);
|
||||
}
|
||||
vals.clear();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
|
@ -1316,7 +1399,7 @@ public class ContourSupport {
|
|||
|
||||
long t1c = System.currentTimeMillis();
|
||||
logger.debug("ContourGenerator.setContourValues(allvalues) took: " + (t1c-t1b));
|
||||
// System.out.println("ContourGenerator init took:" + (t1c-t0));
|
||||
// System.out.println("ContourGenerator init took:" + (t1c-t0));
|
||||
|
||||
try {
|
||||
cgen.generateContours();
|
||||
|
@ -1363,4 +1446,96 @@ public class ContourSupport {
|
|||
if ( ! isCntrsCreated ) return null;
|
||||
return contourGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the worldWrapChecker is true and the gird is split by the map border.
|
||||
* @param imageGridGeometry
|
||||
* @param rastPosToLatLon
|
||||
* @return
|
||||
*/
|
||||
private boolean needWrap(GeneralGridGeometry imageGridGeometry, MathTransform rastPosToLatLon){
|
||||
boolean ret = worldWrapChecker;
|
||||
|
||||
if ( ret ){
|
||||
//minimum, maximum X grid
|
||||
int minx = imageGridGeometry.getGridRange().getLow(0);
|
||||
int maxx = imageGridGeometry.getGridRange().getHigh(0);
|
||||
|
||||
double [] out0 = new double[3];
|
||||
double [] out1 = new double[3];
|
||||
|
||||
//minimum, maximum longitudes
|
||||
try {
|
||||
rastPosToLatLon.transform( new double[]{minx, 0}, 0, out0, 0, 1 );
|
||||
rastPosToLatLon.transform( new double[]{maxx, 0}, 0, out1, 0, 1 );
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
//printStackTrace();
|
||||
ret = false;
|
||||
}
|
||||
|
||||
|
||||
double minLon = ( out0[0] >= 0 ) ? out0[0] : out0[0] +360;
|
||||
double maxLon = ( out1[0] >= 0 ) ? out1[0] : out1[0] +360;
|
||||
|
||||
if ( minLon == 0 && maxLon == 360 ) globalData = true;
|
||||
|
||||
if ( maxLon >= 360 ) maxLon = 359;
|
||||
|
||||
double right = centralMeridian + 180;
|
||||
|
||||
if ( maxLon > minLon ){
|
||||
ret = (right > minLon) && (right < maxLon );
|
||||
}
|
||||
else {
|
||||
ret = !(right > minLon) && (right < maxLon );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum grid number in x direction
|
||||
* @param imageGridGeometry
|
||||
* @return int - maximum grid number in x direction
|
||||
*/
|
||||
private int getMaxGridX(GeneralGridGeometry imageGridGeometry){
|
||||
return imageGridGeometry.getGridRange().getHigh(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map width in screen coordinate.
|
||||
* @return
|
||||
*/
|
||||
private double getMapWidth() {
|
||||
if ( worldWrapChecker ){
|
||||
// double right[] = new double[]{centralMeridian + 180, 0};
|
||||
// double left[] = new double[]{centralMeridian - 180, 0};
|
||||
double right[] = new double[]{-180, 0};
|
||||
double left[] = new double[]{0, 0};
|
||||
|
||||
double screenLeft[] = new double[2];
|
||||
double screenRight[] = new double[2];
|
||||
|
||||
try {
|
||||
double center[] = new double[]{0, 0};
|
||||
double out[] = new double[2];
|
||||
rastPosLatLonToWorldGrid.transform(center, 0, out, 0, 1);
|
||||
zeroLonOnScreen = out[0];
|
||||
|
||||
rastPosLatLonToWorldGrid.transform(left, 0, screenLeft, 0, 1);
|
||||
rastPosLatLonToWorldGrid.transform(right, 0, screenRight, 0, 1);
|
||||
|
||||
return Math.abs(screenRight[0] - screenLeft[0])*2;
|
||||
} catch (TransformException e) {
|
||||
// TODO Auto-generated catch block
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1058,9 +1058,7 @@ public class TestDgdriv {
|
|||
// file = new File(File.separator + dataURI.split("/")[1]
|
||||
// + File.separator + path + File.separator + sb.toString());
|
||||
//} else if (DataMode.getSystemMode() == DataMode.PYPIES) {
|
||||
file = new File(
|
||||
//TODO--OK?? VizApp.getServerDataDir() + File.separator +
|
||||
dataURI.split("/")[1] + File.separator + path
|
||||
file = new File(dataURI.split("/")[1] + File.separator + path
|
||||
+ File.separator + sb.toString());
|
||||
//} else {
|
||||
// file = new File(VizApp.getDataDir() + File.separator
|
||||
|
@ -1069,7 +1067,7 @@ public class TestDgdriv {
|
|||
//}
|
||||
|
||||
if (file != null)
|
||||
filename = file.getAbsolutePath();
|
||||
filename = file.getPath();
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
|
|
@ -303,17 +303,24 @@ public class CNFNative {
|
|||
//System.out.println("Coords:"+coords[0]+" "+coords[coords.length-1]);
|
||||
if ( coords[0].equals2D( coords[coords.length-1]) && (coords.length > 3) ) {
|
||||
//System.out.println("CLOSED EDGE!!!!!!!!!!!!"); // For inner missing areas maybe?
|
||||
LinearRing lr = gf.createLinearRing(coords);
|
||||
// Polygon poly = gf.createPolygon(lr, null);
|
||||
geoms.add(lr);
|
||||
CoordinateList cl = new CoordinateList(coords, false);
|
||||
|
||||
if ( cl.size() >= 4 ){
|
||||
LinearRing lr = gf.createLinearRing(cl.toCoordinateArray());
|
||||
// Polygon poly = gf.createPolygon(lr, null);
|
||||
geoms.add(lr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//System.out.println("OPEN EDGE!!!!!!!!!!!!"); // For missing areas around edge of grid?
|
||||
//LineString ls = gf.createLineString(coords);
|
||||
CoordinateList cl = new CoordinateList(coords, false);
|
||||
LineString ls = gf.createLineString(cl.toCoordinateArray());
|
||||
//System.out.println("EDGE: "+ls.toString());
|
||||
geoms.add(ls);
|
||||
|
||||
if ( cl.size() >= 2 ){
|
||||
LineString ls = gf.createLineString(cl.toCoordinateArray());
|
||||
//System.out.println("EDGE: "+ls.toString());
|
||||
geoms.add(ls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,10 +339,12 @@ public class CNFNative {
|
|||
//System.out.println("GOT... "+ls.getClass().getCanonicalName()+((LineString)ls).getBoundary()+((LineString)ls).getNumPoints());
|
||||
CoordinateList cl = new CoordinateList(ls.getCoordinates(), true);
|
||||
cl.closeRing();
|
||||
LinearRing lr = gf.createLinearRing(cl.toCoordinateArray());
|
||||
lr.normalize();
|
||||
//System.out.println("Merged: "+lr.toString());
|
||||
geoms.add(lr);
|
||||
if ( cl.size() >= 4 ){
|
||||
LinearRing lr = gf.createLinearRing(cl.toCoordinateArray());
|
||||
lr.normalize();
|
||||
//System.out.println("Merged: "+lr.toString());
|
||||
geoms.add(lr);
|
||||
}
|
||||
}
|
||||
|
||||
return geoms.get(0);
|
||||
|
|
|
@ -109,6 +109,7 @@ public class NCNonMapRenderableDisplay extends AbstractRenderableDisplay impleme
|
|||
this.setPaneId( pid );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] getMapCenter() {
|
||||
return getExtent().getCenter();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.eclipse.ui.AbstractSourceProvider;
|
|||
import org.eclipse.ui.ISources;
|
||||
|
||||
//
|
||||
// 12/12/2012 #630 ghull moved from zoom/tools since now set from NcMapEditor refreshPanes()
|
||||
// 12/12/2012 #630 ghull moved from zoom/tools since now set from NatlCntrsEditor refreshPanes()
|
||||
//
|
||||
//
|
||||
public class ZoomStateSourceProvider extends AbstractSourceProvider {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
Name: awips2-ldm
|
||||
Summary: AWIPS II LDM Distribution
|
||||
Version: %{_ldm_version}
|
||||
Release: 5
|
||||
Release: 6
|
||||
Group: AWIPSII
|
||||
BuildRoot: /tmp
|
||||
BuildArch: noarch
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#20130326 1828 rferrel Fix patterns for intlsigmets and text pattern not placing files in proper directory.
|
||||
#20130530 2054 rferrel Minor fix to two grib patterns.
|
||||
#20130624 1966 rferrel The acars pattern changed to place files in the proper subdirectories.
|
||||
Name changes to reflect plugin names for modelsounding, goessounding, poessounding.
|
||||
# Name changes to reflect plugin names for modelsounding, goessounding, poessounding.
|
||||
#***************************************************************
|
||||
# AWIPS 1 PATTERN GRAPHIC ^[PQ].* /redbook/Raw
|
||||
# PGNA00 KWNS 010001 !redbook 1_1/NMCGPHMCD/MCDSUM/PXSF001CN/20110201 0001
|
||||
|
|
Loading…
Add table
Reference in a new issue