Initial import.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/netcdf-basic-widgets@157530 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-10-24 14:16:04 +00:00
parent 360b225bb4
commit 739b4b49ef
110 changed files with 8720 additions and 0 deletions

37
.classpath Normal file
View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/netcdf-basic-widgets-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/netcdf-basic-widgets-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/netcdf-basic-widgets-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

48
.project Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>netcdf-basic-widgets</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
</natures>
</projectDescription>

13
.settings/.jsdtscope Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/webapp"/>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="target/m2e-wtp/web-resources"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>

View File

@ -0,0 +1,3 @@
eclipse.preferences.version=1
googleCloudSqlEnabled=false
localDevMySqlEnabled=true

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
entryPointModules=org.gcube.portlets.widgets.netcdfbasicwidget.netcdfbasicwidgets

View File

@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="netcdf-basic-widgets-0.0.1-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="java-output-path" value="/netcdf-basic-widget/target/classes"/>
<property name="context-root" value="netcdf-basic-widgets"/>
</wb-module>
</project-modules>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.web" version="3.0"/>
</faceted-project>

View File

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary

View File

@ -0,0 +1 @@
Window

View File

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

1
distro/LICENSE Normal file
View File

@ -0,0 +1 @@
${gcube.license}

68
distro/README Normal file
View File

@ -0,0 +1,68 @@
The gCube System - ${name}
--------------------------------------------------
${description}
${gcube.description}
${gcube.funding}
Version
--------------------------------------------------
${version} (${buildDate})
Please see the file named "changelog.xml" in this directory for the release notes.
Authors
--------------------------------------------------
* Giancarlo Panichi (giancarlo.panichi-AT-isti.cnr.it),
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" CNR, Pisa IT
Maintainers
-----------
* Giancarlo Panichi (giancarlo.panichi-AT-isti.cnr.it),
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" CNR, Pisa IT
Download information
--------------------------------------------------
Source code is available from SVN:
${scm.url}
Binaries can be downloaded from the gCube website:
${gcube.website}
Installation
--------------------------------------------------
Installation documentation is available on-line in the gCube Wiki:
https://wiki.gcube-system.org/gcube/DataMiner_Manager
Documentation
--------------------------------------------------
Documentation is available on-line in the gCube Wiki:
https://wiki.gcube-system.org/gcube/DataMiner_Manager
Support
--------------------------------------------------
Bugs and support requests can be reported in the gCube issue tracking tool:
${gcube.issueTracking}
Licensing
--------------------------------------------------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

5
distro/changelog.xml Normal file
View File

@ -0,0 +1,5 @@
<ReleaseNotes>
<Changeset component="${groupId}.${artifactId}.1-0-0" date="2017-11-02">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

32
distro/descriptor.xml Normal file
View File

@ -0,0 +1,32 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${build.finalName}.${project.packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

27
distro/profile.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource>
<ID></ID>
<Type>Service</Type>
<Profile>
<Description>${project.description}</Description>
<Class>DataAnalysis</Class>
<Name>${project.name}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Description>${project.description}</Description>
<Name>${project.name}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</MavenCoordinates>
<Type>library</Type>
<Files>
<File>${project.build.finalName}.${project.packaging}</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

343
pom.xml Normal file
View File

@ -0,0 +1,343 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>netcdf-basic-widgets</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>netcdf-basic-widgets</name>
<description>netcdf-basic-widgets</description>
<scm>
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/netcdf-basic-widgets</url>
</scm>
<developers>
<developer>
<name>Giancarlo Panichi</name>
<email>g.panichi@isti.cnr.it</email>
<organization>CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"</organization>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
</developer>
</developers>
<properties>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<distroDirectory>distro</distroDirectory>
<configDirectory>config</configDirectory>
<!-- Java Version -->
<javaVersion>1.8</javaVersion>
<!-- GWT configuration -->
<gwtVersion>2.8.1</gwtVersion>
<gwtLogVersion>3.3.2</gwtLogVersion>
<KEYS>${env.KEYS}</KEYS>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<profiles>
<profile>
<id>localRun</id>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwtVersion}</version>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
</dependency>
<!-- PORTAL -->
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>client-context-library</artifactId>
<version>[1.0.0-SNAPSHOT,)</version>
<scope>compile</scope>
</dependency>
<!-- Authorization -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<scope>provided</scope>
</dependency>
<!-- Storage -->
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-wrapper</artifactId>
<scope>provided</scope>
</dependency>
<!-- Home Library -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-model</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/edu.ucar/netcdf -->
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>netcdf</artifactId>
<version>4.3.23</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.gdal/gdal <dependency> <groupId>org.gdal</groupId>
<artifactId>gdal</artifactId> <version>2.2.1</version> </dependency> -->
<!-- LOGGING -->
<dependency>
<groupId>com.allen-sauer.gwt.log</groupId>
<artifactId>gwt-log</artifactId>
<version>${gwtLogVersion}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
</dependency>
<!-- JUnit TEST -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<!-- ASM -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<skipTests>true</skipTests>
<exclude>**/GwtTest*.java</exclude>
</configuration>
<!-- TODO check if needed -->
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.16</version>
</dependency>
</dependencies>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwtVersion}</version>
<executions>
<execution>
<configuration>
<extraJvmArgs>-Xss512m -Xmx3072m -XX:MaxPermSize=2048m</extraJvmArgs>
</configuration>
<goals>
<!-- <goal>test</goal> -->
<goal>resources</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>NetCDFBasicWidgets.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<module>org.gcube.portlets.widgets.netcdfbasicwidgets.netcdfbasicwidgets</module>
<includes>**/GwtTest*.java</includes>
</configuration>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
<warName>${project.build.finalName}</warName>
</configuration>
</plugin>
<!-- Maven Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${javaVersion}</source>
<target>${javaVersion}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>unidata.ucar</id>
<url>https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>boundlessgeo</id>
<url>http://repo.boundlessgeo.com/main/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,53 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent.SelectVariableEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets.NetCDFPreviewDialog;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.shared.GWT;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFBasicWidgets implements EntryPoint {
/**
* {@inheritDoc}
*/
public void onModuleLoad() {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loadMainPanel();
}
});
}
private void loadMainPanel() {
GWT.log("NetcdfBasicWidgetsManager");
// Example
SelectVariableEventHandler handler=new SelectVariableEventHandler() {
@Override
public void onResponse(SelectVariableEvent event) {
GWT.log("SelectVariable Response: "+event);
}
};
NetCDFPreviewDialog dialog=new NetCDFPreviewDialog();
dialog.addSelectVariableEventHandler(handler);
}
}

View File

@ -0,0 +1,63 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.event;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFData;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Select Area Dialog Event
*
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFDataEvent extends GwtEvent<NetCDFDataEvent.NetCDFDataEventHandler> {
public static Type<NetCDFDataEventHandler> TYPE = new Type<NetCDFDataEventHandler>();
private NetCDFData netCDFData;
public interface NetCDFDataEventHandler extends EventHandler {
void onNetCDFDataReady(NetCDFDataEvent event);
}
public interface HasNetCDFDataEventHandler extends HasHandlers {
public HandlerRegistration addNetCDFDataEventHandler(NetCDFDataEventHandler handler);
}
public NetCDFDataEvent(NetCDFData netCDFData) {
this.netCDFData = netCDFData;
}
@Override
protected void dispatch(NetCDFDataEventHandler handler) {
handler.onNetCDFDataReady(this);
}
@Override
public Type<NetCDFDataEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<NetCDFDataEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, NetCDFDataEvent event) {
source.fireEvent(event);
}
public NetCDFData getNetCDFData() {
return netCDFData;
}
@Override
public String toString() {
return "NetCDFDataEvent [netCDFData=" + netCDFData + "]";
}
}

View File

@ -0,0 +1,70 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.event;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Select Area Dialog Event
*
*
* @author Giancarlo Panichi
*
*
*/
public class SampleVariableDataEvent extends GwtEvent<SampleVariableDataEvent.SampleVariableDataEventHandler> {
public static Type<SampleVariableDataEventHandler> TYPE = new Type<SampleVariableDataEventHandler>();
private VariableData variableData;
private NetCDFValues sampleValues;
public interface SampleVariableDataEventHandler extends EventHandler {
void onSample(SampleVariableDataEvent event);
}
public interface HasSampleVariableDataEventHandler extends HasHandlers {
public HandlerRegistration addSampleVariableDataEventHandler(SampleVariableDataEventHandler handler);
}
public SampleVariableDataEvent(VariableData variableData, NetCDFValues sampleValues) {
this.variableData = variableData;
this.sampleValues = sampleValues;
}
@Override
protected void dispatch(SampleVariableDataEventHandler handler) {
handler.onSample(this);
}
@Override
public Type<SampleVariableDataEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<SampleVariableDataEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, SampleVariableDataEvent event) {
source.fireEvent(event);
}
public VariableData getVariableData() {
return variableData;
}
public NetCDFValues getSampleValues() {
return sampleValues;
}
@Override
public String toString() {
return "SampleVariableDataEvent [variableData=" + variableData + ", sampleValues=" + sampleValues + "]";
}
}

View File

@ -0,0 +1,94 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.event;
import java.util.ArrayList;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Select Area Dialog Event
*
*
* @author Giancarlo Panichi
*
*
*/
public class SelectVariableEvent extends GwtEvent<SelectVariableEvent.SelectVariableEventHandler> {
public static Type<SelectVariableEventHandler> TYPE = new Type<SelectVariableEventHandler>();
private SelectVariableEventType selectVariableEventType;
private ArrayList<VariableData> variables;
private String errorMessage;
private Exception exception;
public interface SelectVariableEventHandler extends EventHandler {
void onResponse(SelectVariableEvent event);
}
public interface HasSelectVariableEventHandler extends HasHandlers {
public HandlerRegistration addSelectVariableEventHandler(SelectVariableEventHandler handler);
}
public SelectVariableEvent(SelectVariableEventType selectVariableEventType) {
this.selectVariableEventType = selectVariableEventType;
}
@Override
protected void dispatch(SelectVariableEventHandler handler) {
handler.onResponse(this);
}
@Override
public Type<SelectVariableEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<SelectVariableEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, SelectVariableEvent deleteItemEvent) {
source.fireEvent(deleteItemEvent);
}
public SelectVariableEventType getSelectVariableEventType() {
return selectVariableEventType;
}
public ArrayList<VariableData> getVariables() {
return variables;
}
public void setVariables(ArrayList<VariableData> variables) {
this.variables = variables;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public Exception getException() {
return exception;
}
public void setException(Exception exception) {
this.exception = exception;
}
@Override
public String toString() {
return "SelectVariableEvent [selectVariableEventType=" + selectVariableEventType + ", variables=" + variables
+ ", errorMessage=" + errorMessage + ", exception=" + exception + "]";
}
}

View File

@ -0,0 +1,60 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.event;
import java.util.Arrays;
import java.util.List;
/**
*
* @author Giancarlo Panichi
*
*
*/
public enum SelectVariableEventType {
Completed("Completed"), Failed("Failed"), Aborted("Aborted");
/**
*
* @param id id
*/
private SelectVariableEventType(final String id) {
this.id = id;
}
private final String id;
@Override
public String toString() {
return id;
}
public String getLabel() {
return id;
}
public String getId() {
return id;
}
/**
*
* @param id id
* @return select area dialog event type
*/
public static SelectVariableEventType getTypeFromId(String id) {
if (id == null || id.isEmpty())
return null;
for (SelectVariableEventType type : values()) {
if (type.id.compareToIgnoreCase(id) == 0) {
return type;
}
}
return null;
}
public static List<SelectVariableEventType> asList() {
List<SelectVariableEventType> list = Arrays.asList(values());
return list;
}
}

View File

@ -0,0 +1,161 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.model;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SampleVariableDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SampleVariableDataEvent.SampleVariableDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.rpc.NetCDFBasicWidgetServiceAsync;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.Constants;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.AttributeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.view.client.HasData;
import com.google.gwt.view.client.ListDataProvider;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFDataModel {
private NetCDFData netCDFData;
private ArrayList<NetCDFDataEventHandler> handlers = new ArrayList<>();
private ListDataProvider<VariableData> variableDataProvider = new ListDataProvider<>();
private ListDataProvider<AttributeData> globalAttributeDataProvider = new ListDataProvider<>();
public NetCDFDataModel() {
retrieveData();
}
public void addVariableDataDisplay(HasData<VariableData> display) {
variableDataProvider.addDataDisplay(display);
}
public ListDataProvider<VariableData> getVariableDataProvider() {
return variableDataProvider;
}
public void addGlobalAttributeDataDisplay(HasData<AttributeData> display) {
globalAttributeDataProvider.addDataDisplay(display);
}
public ListDataProvider<AttributeData> getGlobalAttributeDataProvider() {
return globalAttributeDataProvider;
}
/**
* Refresh all displays.
*/
public void refreshVariableDisplays() {
variableDataProvider.refresh();
}
/**
* Refresh all displays.
*/
public void refreshGlobalAttributeDisplays() {
globalAttributeDataProvider.refresh();
}
public void retrieveData() {
NetCDFBasicWidgetServiceAsync.INSTANCE.getNetCDFFromPublicLink("", new AsyncCallback<NetCDFData>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error retrieving NetCDFData: " + caught.getLocalizedMessage(), caught);
}
@Override
public void onSuccess(NetCDFData ncData) {
netCDFData = ncData;
GWT.log("NetCDFData retrieved: " + netCDFData);
List<VariableData> variables = variableDataProvider.getList();
variables.addAll(ncData.getVariables());
List<AttributeData> globalAttributes = globalAttributeDataProvider.getList();
globalAttributes.addAll(ncData.getDetail().getGlobalAttributeDataList());
fireNetCDFDataEvent();
}
});
}
public void close() {
NetCDFBasicWidgetServiceAsync.INSTANCE.closeNetCDF(netCDFData.getNetCDFId(), new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error closing NetCDFData: " + caught.getLocalizedMessage(), caught);
}
@Override
public void onSuccess(Void v) {
GWT.log("NetCDFData closed");
}
});
}
public void fireNetCDFDataEvent() {
NetCDFDataEvent event = new NetCDFDataEvent(netCDFData);
for (NetCDFDataEventHandler handler : handlers) {
handler.onNetCDFDataReady(event);
}
}
public void addNetCDFDataEventHandler(NetCDFDataEventHandler handler) {
handlers.add(handler);
}
public void retrieveSampleOfVariable(final SampleVariableDataEventHandler handler, VariableData variableData) {
readSampleOfVariable(handler, variableData);
}
private void readSampleOfVariable(final SampleVariableDataEventHandler handler, VariableData variableData) {
NetCDFBasicWidgetServiceAsync.INSTANCE.readDataVariable(netCDFData.getNetCDFId(), variableData, true,
Constants.SAMPLE_LENGHT, new AsyncCallback<NetCDFValues>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error retrieving sample for Variable " + variableData.getFullName() + ": "
+ caught.getLocalizedMessage(), caught);
}
@Override
public void onSuccess(NetCDFValues result) {
GWT.log("VariableData: " + variableData.getFullName());
GWT.log("NetCDFValues: " + result);
SampleVariableDataEvent event = new SampleVariableDataEvent(variableData, result);
handler.onSample(event);
}
});
}
}

View File

@ -0,0 +1,66 @@
@CHARSET "UTF-8";
/* Dialog tool button */
.dialog-tool-button-text {
margin-left: -20px;
margin-top: 2px;
}
.dialog-tool-button-text:hover {
margin-left: -20px;
margin-top: 0px;
}
.dialog-tool-button-icon {
height: 20px;
}
.dialog-tool-button-icon:hover {
height: 20px;
border: 1px solid #222;
}
/**/
.area-selection-panel {
border: 1px solid #ccc;
background-color: white;
margin-top: 4px;
margin-bottom: 4px;
}
.area-selection-content {
margin: 4px;
}
/* Progress */
.progress-bar-container {
width: 100%;
height: 25px;
position: relative;
background-color: #f1f1f1;
}
.progress-bar {
color: #fff;
background-color: #a5a5a5;
height: 100%;
position: absolute;
line-height: inherit;
}
.progress-bar-text {
text-align: center;
color: #2d2d2d;
position: absolute;
width: 100%;
margin-top: 5px;
}
/* Form */
.wkt-geometry-text-area {
width: 400px !important;
}
.combo-geometry-type {
width: 406px !important;
}

View File

@ -0,0 +1,43 @@
/**
*
*/
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.resource;
import com.google.gwt.resources.client.CssResource;
/**
*
* @author Giancarlo Panichi
*
*
*/
public interface NetCDFBasicCSS extends CssResource {
@ClassName("area-selection-panel")
public String getAreaSelectionPanel();
@ClassName("area-selection-content")
public String getAreaSelectionContent();
@ClassName("dialog-tool-button-text")
public String getDialogToolButtonText();
@ClassName("dialog-tool-button-icon")
public String getDialogToolButtonIcon();
@ClassName("progress-bar-container")
public String getProgressBarContainer();
@ClassName("progress-bar")
public String getProgressBar();
@ClassName("progress-bar-text")
public String getProgressBarText();
@ClassName("wkt-geometry-text-area")
public String getWKTGeometryTextArea();
@ClassName("combo-geometry-type")
public String getComboGeometryType();
}

View File

@ -0,0 +1,25 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.resource;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
/**
*
* @author Giancarlo Panichi
*
*
*/
public interface NetCDFBasicResources extends ClientBundle {
public static final NetCDFBasicResources INSTANCE = GWT.create(NetCDFBasicResources.class);
@Source("NetCDFBasic.css")
NetCDFBasicCSS olBasicCSS();
@Source("tool-button-close_20.png")
ImageResource toolButtonClose20();
@Source("search_16.png")
ImageResource search16();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

View File

@ -0,0 +1,33 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.rpc;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.exception.ServiceException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFId;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.session.UserInfo;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
*
* @author Giancarlo Panichi
*
*
*/
@RemoteServiceRelativePath("netcdfservice")
public interface NetCDFBasicWidgetService extends RemoteService {
public UserInfo hello() throws ServiceException;
public NetCDFData getNetCDFFromPublicLink(String publicLink) throws ServiceException;
public NetCDFData getNetCDFFromItem(String itemId) throws ServiceException;
public void closeNetCDF(NetCDFId netCDFId) throws ServiceException;
public NetCDFValues readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit) throws ServiceException;
}

View File

@ -0,0 +1,34 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.rpc;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFId;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.session.UserInfo;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author Giancarlo Panichi
*
*
*/
public interface NetCDFBasicWidgetServiceAsync {
public static NetCDFBasicWidgetServiceAsync INSTANCE = (NetCDFBasicWidgetServiceAsync) GWT
.create(NetCDFBasicWidgetService.class);
void hello(AsyncCallback<UserInfo> callback);
void getNetCDFFromPublicLink(String publicLink, AsyncCallback<NetCDFData> callback);
void getNetCDFFromItem(String itemId, AsyncCallback<NetCDFData> callback);
void closeNetCDF(NetCDFId netCDFId, AsyncCallback<Void> callback);
void readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit,
AsyncCallback<NetCDFValues> callback);
}

View File

@ -0,0 +1,70 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.util;
import com.google.gwt.core.client.Callback;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class AlertDialog extends DialogBox implements ClickHandler {
private Callback<Void, Void> callback;
protected HTML msg;
protected double msgMinWidth=200;
protected double msgMinHeight=30;
public AlertDialog(String title, String text, int zIndex) {
init(title, text, zIndex);
}
public AlertDialog(String title, String text, int zIndex, Callback<Void, Void> callback) {
init(title, text, zIndex);
}
private void init(String title, String text, int zIndex) {
setText(title);
setModal(true);
setGlassEnabled(true);
Button closeButton = new Button("Close", this);
msg = new HTML(text, true);
msg.getElement().getStyle().setProperty("minWidth", msgMinWidth, Unit.PX);
msg.getElement().getStyle().setProperty("minHeight",msgMinHeight, Unit.PX);
DockPanel dock = new DockPanel();
dock.setSpacing(4);
dock.add(closeButton, DockPanel.SOUTH);
dock.add(msg, DockPanel.CENTER);
dock.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_CENTER);
dock.setWidth("100%");
setWidget(dock);
if(zIndex>0){
getGlassElement().getStyle().setZIndex(zIndex+4);
getElement().getStyle().setZIndex(zIndex+5);
}
center();
}
@Override
public void onClick(ClickEvent event) {
if(callback!=null){
callback.onSuccess(null);
}
hide();
}
}

View File

@ -0,0 +1,27 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.util;
import com.google.gwt.core.client.Callback;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class GWTMessages {
public static void alert(String title, String text, int zIndex) {
AlertDialog alertDialog = new AlertDialog(title, text, zIndex);
alertDialog.show();
}
public static void alert(String title, String text,int zIndex,
Callback<Void, Void> callback) {
AlertDialog alertDialog = new AlertDialog(title, text, zIndex, callback);
alertDialog.show();
}
}

View File

@ -0,0 +1,113 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.util;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.resource.NetCDFBasicResources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class WaitDialog extends DialogBox {
private HandlerRegistration resizeHandlerRegistration;
private HTML msg;
private String msgWidth = "200px";
private String msgHeight = "25px";
private Timer t;
public WaitDialog(int zIndex){
init("Please Wait", "Working...", zIndex);
}
public WaitDialog(String title, String text, int zIndex) {
init(title, text, zIndex);
}
private void init(String title, String text, int zIndex) {
GWT.log("WaitDialog:[title=" + title + ", text=" + text + "]");
NetCDFBasicResources.INSTANCE.olBasicCSS().ensureInjected();
setModal(true);
setGlassEnabled(true);
initHandler();
setText(title);
msg = new HTML("<div class='"
+ NetCDFBasicResources.INSTANCE.olBasicCSS().getProgressBarContainer()
+ "'>" + "<div class='"
+ NetCDFBasicResources.INSTANCE.olBasicCSS().getProgressBar()
+ "' style='width:50%'></div>" + "<div class='"
+ NetCDFBasicResources.INSTANCE.olBasicCSS().getProgressBarText() + "'>"
+ text + "</div>" + "</div><br>");
msg.setWidth(msgWidth);
msg.setHeight(msgHeight);
setWidget(msg);
if(zIndex>0){
getGlassElement().getStyle().setZIndex(zIndex+2);
getElement().getStyle().setZIndex(zIndex+3);
}
center();
startTimer();
}
private void initHandler() {
resizeHandlerRegistration = Window
.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
center();
}
});
}
private void startTimer() {
t = new Timer() {
private int width = 0;
@Override
public void run() {
if (width > 100) {
width = 0;
}
msg.getElement().getFirstChildElement().getFirstChildElement()
.getStyle().setWidth(width, Unit.PCT);
width += 10;
}
};
// Schedule the timer to run once in 200 millseconds.
t.scheduleRepeating(400);
}
private void stopTimer() {
t.cancel();
}
@Override
public void hide() {
stopTimer();
if (resizeHandlerRegistration != null) {
resizeHandlerRegistration.removeHandler();
resizeHandlerRegistration = null;
}
super.hide();
}
}

View File

@ -0,0 +1,478 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.AttributeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.RangeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.DefaultSelectionEventManager;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.SelectionModel;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
private static final String HEIGHT = "350px";
private static final String WIDTH = "680px";
private static final String ATTRIBUTE_DATA_GRID_HEIGHT = "155px";
private static final String ATTRIBUTE_DATA_GRID_WIDTH = "608px";
private static final String RANGE_DATA_GRID_HEIGHT = "105px";
private static final String RANGE_DATA_GRID_WIDTH = "608px";
private static final NetCDFPreviewMessages messages = GWT.create(NetCDFPreviewMessages.class);
private ListBox variablesBox;
private ArrayList<VariableData> variables;
private NetCDFDataModel netCDFDataModel;
private ListDataProvider<AttributeData> attributesOfVariableProvider;
private DataGrid<AttributeData> attributesOfVariableGrid;
private SimplePager attributesOfVariablePager;
private ListDataProvider<RangeData> rangesOfVariableProvider;
private DataGrid<RangeData> rangesOfVariableGrid;
private SimplePager rangesOfVariablePager;
public DetailPanel(NetCDFDataModel netCDFDataModel) {
this.netCDFDataModel = netCDFDataModel;
init();
create();
}
private void init() {
setHeight(HEIGHT);
setWidth(WIDTH);
}
private void create() {
netCDFDataModel.addNetCDFDataEventHandler(this);
createAttributesOfVariableGrid();
createRangesOfVariableGrid();
// ////////
// Form
FlexTable detailFlexTable = new FlexTable();
detailFlexTable.setCellSpacing(2);
//detailFlexTable.setBorderWidth(1);
// Add a drop box with the list types
variablesBox = new ListBox();
variablesBox.setEnabled(false);
variablesBox.ensureDebugId("detailPanelVariablesBox");
variablesBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
retrieveVariableData(variablesBox.getSelectedValue());
}
});
detailFlexTable.setHTML(0, 0, "Variable:");
detailFlexTable.setWidget(0, 1, variablesBox);
//Attributes
detailFlexTable.getFlexCellFormatter().setVerticalAlignment(1, 0,HasVerticalAlignment.ALIGN_TOP);
detailFlexTable.setHTML(1, 0, "Attributes:");
attributesOfVariablePager.getElement().getStyle().setProperty("margin", "auto");
VerticalPanel vpAttributes=new VerticalPanel();
vpAttributes.getElement().getStyle().setBackgroundColor("#f8f8fb");
vpAttributes.add(attributesOfVariableGrid);
vpAttributes.add(attributesOfVariablePager);
detailFlexTable.setWidget(1, 1, vpAttributes);
//Ranges
detailFlexTable.getFlexCellFormatter().setVerticalAlignment(2, 0,HasVerticalAlignment.ALIGN_TOP);
detailFlexTable.setHTML(2, 0, "Ranges:");
//detailFlexTable.getFlexCellFormatter().setColSpan(1, 0, 2);
rangesOfVariablePager.getElement().getStyle().setProperty("margin", "auto");
//detailFlexTable.setWidget(2, 1, attributesOfVariablePager);
VerticalPanel vpRanges=new VerticalPanel();
vpRanges.getElement().getStyle().setBackgroundColor("#f8f8fb");
vpRanges.add(rangesOfVariableGrid);
vpRanges.add(rangesOfVariablePager);
detailFlexTable.setWidget(2, 1, vpRanges);
setWidget(detailFlexTable);
}
public void refresh() {
refreshAttributes();
refreshRanges();
}
private void retrieveVariableData(String selectedValue) {
VariableData variableRequested = null;
if (Integer.valueOf(selectedValue) != -1) {
for (VariableData variableData : variables) {
if (variableData.getId() == Integer.valueOf(selectedValue)) {
variableRequested = variableData;
break;
}
}
if (variableRequested != null) {
GWT.log("Variable retrieved: "+variableRequested);
List<AttributeData> attributesOfVariable = attributesOfVariableProvider.getList();
attributesOfVariable.clear();
attributesOfVariable.addAll(variableRequested.getAttributes());
attributesOfVariableProvider.refresh();
refreshAttributes();
List<RangeData> rangesOfVariable = rangesOfVariableProvider.getList();
rangesOfVariable.clear();
rangesOfVariable.addAll(variableRequested.getRanges());
rangesOfVariableProvider.refresh();
refreshRanges();
} else {
GWT.log("Variable not retrieved: "+selectedValue);
}
}
}
@Override
public void onNetCDFDataReady(NetCDFDataEvent event) {
variables = event.getNetCDFData().getVariables();
variablesBox.clear();
variablesBox.addItem(" ", "-1");
for (VariableData varData : variables) {
variablesBox.addItem(varData.getFullName(), String.valueOf(varData.getId()));
}
variablesBox.setEnabled(true);
//
attributesOfVariableProvider.addDataDisplay(attributesOfVariableGrid);
attributesOfVariableProvider.refresh();
rangesOfVariableProvider.addDataDisplay(rangesOfVariableGrid);
rangesOfVariableProvider.refresh();
}
private void createAttributesOfVariableGrid() {
/*
* Set a key provider that provides a unique key for each contact. If
* key is used to identify contacts when fields (such as the name and
* address) change.
*/
attributesOfVariableGrid = new DataGrid<AttributeData>(8, AttributeData.KEY_PROVIDER);
attributesOfVariableGrid.setWidth(ATTRIBUTE_DATA_GRID_WIDTH);
attributesOfVariableGrid.setHeight(ATTRIBUTE_DATA_GRID_HEIGHT);
/*
* Do not refresh the headers every time the data is updated. The footer
* depends on the current data, so we do not disable auto refresh on the
* footer.
*/
attributesOfVariableGrid.setAutoHeaderRefreshDisabled(true);
// Set the message to display when the table is empty.
attributesOfVariableGrid.setEmptyTableWidget(new Label(messages.dataGridAttributeOfVariableEmpty()));
// Attach a column sort handler to the ListDataProvider to sort the
// list.
attributesOfVariableProvider = new ListDataProvider<>();
ListHandler<AttributeData> sortHandler = new ListHandler<AttributeData>(attributesOfVariableProvider.getList());
attributesOfVariableGrid.addColumnSortHandler(sortHandler);
// Create a Pager to control the table.
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
attributesOfVariablePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
attributesOfVariablePager.setDisplay(attributesOfVariableGrid);
// Add a selection model so we can select cells.
final MultiSelectionModel<AttributeData> selectionModel = new MultiSelectionModel<AttributeData>(
AttributeData.KEY_PROVIDER);
attributesOfVariableGrid.setSelectionModel(selectionModel,
DefaultSelectionEventManager.<AttributeData>createCheckboxManager());
// Initialize the columns.
initAttributesTableColumns(selectionModel, sortHandler);
}
public void refreshAttributes() {
attributesOfVariableGrid.redraw();
}
private void initAttributesTableColumns(SelectionModel<AttributeData> selectionModel,
ListHandler<AttributeData> sortHandler) {
// Checkbox column. This table will uses a checkbox column for
// selection.
// Alternatively, you can call dataGrid.setSelectionEnabled(true) to
// enable
// mouse selection.
/*
* Column<VariableData, Boolean> checkColumn = new Column<VariableData,
* Boolean>(new CheckboxCell(true, false)) {
*
* @Override public Boolean getValue(VariableData object) { // Get the
* value from the selection model. return
* selectionModel.isSelected(object); } };
* dataGrid.addColumn(checkColumn,
* SafeHtmlUtils.fromSafeConstant("<br/>"));
* dataGrid.setColumnWidth(checkColumn, 40, Unit.PX);
*/
// Fullname
Column<AttributeData, String> fullnameColum = new Column<AttributeData, String>(new TextCell()) {
@Override
public String getValue(AttributeData object) {
return object.getFullName();
}
};
fullnameColum.setSortable(true);
sortHandler.setComparator(fullnameColum, new Comparator<AttributeData>() {
@Override
public int compare(AttributeData o1, AttributeData o2) {
return o1.getFullName().compareTo(o2.getFullName());
}
});
attributesOfVariableGrid.addColumn(fullnameColum, messages.columnFullname());
attributesOfVariableGrid.setColumnWidth(fullnameColum, 130, Unit.PX);
// DataType
Column<AttributeData, String> dataTypeColumn = new Column<AttributeData, String>(new TextCell()) {
@Override
public String getValue(AttributeData object) {
return object.getDataType();
}
};
dataTypeColumn.setSortable(true);
sortHandler.setComparator(dataTypeColumn, new Comparator<AttributeData>() {
@Override
public int compare(AttributeData o1, AttributeData o2) {
return o1.getDataType().compareTo(o2.getDataType());
}
});
attributesOfVariableGrid.addColumn(dataTypeColumn, messages.columnDataType());
attributesOfVariableGrid.setColumnWidth(dataTypeColumn, 80, Unit.PX);
// Values
Column<AttributeData, String> valuesColumn = new Column<AttributeData, String>(new TextCell()) {
@Override
public String getValue(AttributeData object) {
return String.valueOf(object.getValues());
}
};
valuesColumn.setSortable(true);
sortHandler.setComparator(valuesColumn, new Comparator<AttributeData>() {
@Override
public int compare(AttributeData o1, AttributeData o2) {
return o1.getValues().compareTo(o2.getValues());
}
});
attributesOfVariableGrid.addColumn(valuesColumn, messages.columnValue());
// dataGrid.setColumnWidth(valuesColumn, 40, Unit.PX);
}
public Set<AttributeData> selecetedAttributes() {
@SuppressWarnings("unchecked")
Set<AttributeData> selected = ((MultiSelectionModel<AttributeData>) attributesOfVariableGrid
.getSelectionModel()).getSelectedSet();
return selected;
}
private void createRangesOfVariableGrid() {
/*
* Set a key provider that provides a unique key for each contact. If
* key is used to identify contacts when fields (such as the name and
* address) change.
*/
rangesOfVariableGrid = new DataGrid<RangeData>(8, RangeData.KEY_PROVIDER);
rangesOfVariableGrid.setWidth(RANGE_DATA_GRID_WIDTH);
rangesOfVariableGrid.setHeight(RANGE_DATA_GRID_HEIGHT);
/*
* Do not refresh the headers every time the data is updated. The footer
* depends on the current data, so we do not disable auto refresh on the
* footer.
*/
rangesOfVariableGrid.setAutoHeaderRefreshDisabled(true);
// Set the message to display when the table is empty.
rangesOfVariableGrid.setEmptyTableWidget(new Label(messages.dataGridRangeOfVariableEmpty()));
// Attach a column sort handler to the ListDataProvider to sort the
// list.
rangesOfVariableProvider = new ListDataProvider<>();
ListHandler<RangeData> sortHandler = new ListHandler<RangeData>(rangesOfVariableProvider.getList());
rangesOfVariableGrid.addColumnSortHandler(sortHandler);
// Create a Pager to control the table.
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
rangesOfVariablePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
rangesOfVariablePager.setDisplay(rangesOfVariableGrid);
// Add a selection model so we can select cells.
final MultiSelectionModel<RangeData> selectionModel = new MultiSelectionModel<RangeData>(
RangeData.KEY_PROVIDER);
rangesOfVariableGrid.setSelectionModel(selectionModel,
DefaultSelectionEventManager.<RangeData>createCheckboxManager());
// Initialize the columns.
initRangesTableColumns(selectionModel, sortHandler);
}
public void refreshRanges() {
rangesOfVariableGrid.redraw();
}
private void initRangesTableColumns(SelectionModel<RangeData> selectionModel,
ListHandler<RangeData> sortHandler) {
//Name
Column<RangeData, String> nameColum = new Column<RangeData, String>(new TextCell()) {
@Override
public String getValue(RangeData object) {
return object.getName();
}
};
nameColum.setSortable(true);
sortHandler.setComparator(nameColum, new Comparator<RangeData>() {
@Override
public int compare(RangeData o1, RangeData o2) {
return o1.getName().compareTo(o2.getName());
}
});
rangesOfVariableGrid.addColumn(nameColum, messages.columnName());
rangesOfVariableGrid.setColumnWidth(nameColum, 130, Unit.PX);
// N
Column<RangeData, String> nColumn = new Column<RangeData, String>(new TextCell()) {
@Override
public String getValue(RangeData object) {
return String.valueOf(object.getN());
}
};
nColumn.setSortable(true);
sortHandler.setComparator(nColumn, new Comparator<RangeData>() {
@Override
public int compare(RangeData o1, RangeData o2) {
return (o1.getN() < o2.getN()) ? -1 : ((o1.getN() == o2.getN()) ? 0 : 1);
}
});
rangesOfVariableGrid.addColumn(nColumn, messages.columnN());
rangesOfVariableGrid.setColumnWidth(nColumn, 80, Unit.PX);
// First
Column<RangeData, String> firstColumn = new Column<RangeData, String>(new TextCell()) {
@Override
public String getValue(RangeData object) {
return String.valueOf(object.getFirst());
}
};
firstColumn.setSortable(true);
sortHandler.setComparator(firstColumn, new Comparator<RangeData>() {
@Override
public int compare(RangeData o1, RangeData o2) {
return (o1.getFirst() < o2.getFirst()) ? -1 : ((o1.getFirst() == o2.getFirst()) ? 0 : 1);
}
});
rangesOfVariableGrid.addColumn(firstColumn, messages.columnFirst());
rangesOfVariableGrid.setColumnWidth(firstColumn, 80, Unit.PX);
// Stride
Column<RangeData, String> strideColumn = new Column<RangeData, String>(new TextCell()) {
@Override
public String getValue(RangeData object) {
return String.valueOf(object.getStride());
}
};
strideColumn.setSortable(true);
sortHandler.setComparator(strideColumn, new Comparator<RangeData>() {
@Override
public int compare(RangeData o1, RangeData o2) {
return (o1.getStride() < o2.getStride()) ? -1 : ((o1.getStride() == o2.getStride()) ? 0 : 1);
}
});
rangesOfVariableGrid.addColumn(strideColumn, messages.columnStride());
// dataGrid.setColumnWidth(valuesColumn, 40, Unit.PX);
}
public Set<RangeData> selecetedRanges() {
@SuppressWarnings("unchecked")
Set<RangeData> selected = ((MultiSelectionModel<RangeData>) rangesOfVariableGrid
.getSelectionModel()).getSelectedSet();
return selected;
}
}

View File

@ -0,0 +1,62 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets;
import java.util.Arrays;
import java.util.List;
/**
*
* @author Giancarlo Panichi
*
*
*/
public enum GeometryType {
Point("Point"), LineString("LineString"), Polygon("Polygon"), Circle(
"Circle"), Triangle("Triangle"), Square("Square"), Pentagon(
"Pentagon"), Hexagon("Hexagon"), Box("Box"), None("None");
/**
*
* @param label label
*/
private GeometryType(final String label) {
this.label = label;
}
private final String label;
@Override
public String toString() {
return label;
}
public String getLabel() {
return label;
}
public String getId() {
return name();
}
/**
*
* @param label label
* @return geometry type
*/
public static GeometryType getFromLabel(String label) {
if (label == null || label.isEmpty())
return null;
for (GeometryType type : values()) {
if (type.label.compareToIgnoreCase(label) == 0) {
return type;
}
}
return null;
}
public static List<GeometryType> asList() {
List<GeometryType> list = Arrays.asList(values());
return list;
}
}

View File

@ -0,0 +1,264 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets;
import java.util.Comparator;
import java.util.Set;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.AttributeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFDetailData;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.DefaultSelectionEventManager;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.SelectionModel;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class InfoPanel extends SimplePanel implements NetCDFDataEventHandler {
private static final String HEIGHT = "350px";
private static final String WIDTH = "680px";
private static final String DATA_GRID_HEIGHT = "210px";
private static final String DATA_GRID_WIDTH = "608px";
private final NetCDFPreviewMessages messages = GWT.create(NetCDFPreviewMessages.class);
private NetCDFDataModel netCDFDataModel;
private DataGrid<AttributeData> globalAttributesDataGrid;
private SimplePager globalAttributesPager;
private TextBox typeId;
private TextBox typeDescription;
private TextBox typeVersion;
public InfoPanel(NetCDFDataModel netCDFDataModel) {
this.netCDFDataModel = netCDFDataModel;
init();
create();
}
private void init() {
setHeight(HEIGHT);
setWidth(WIDTH);
}
private void create() {
netCDFDataModel.addNetCDFDataEventHandler(this);
createGrid();
// ////////
// Form
FlexTable infoFlexTable = new FlexTable();
infoFlexTable.setCellSpacing(2);
/*
* info = new TextBox(); info.setReadOnly(true);
* infoFlexTable.setHTML(0, 0, "Info:"); infoFlexTable.setWidget(0, 1,
* info);
*
* title = new TextBox(); title.setReadOnly(true);
* infoFlexTable.setHTML(1, 0, "Title:"); infoFlexTable.setWidget(1, 1,
* title);
*/
typeId = new TextBox();
typeId.setReadOnly(true);
infoFlexTable.setHTML(0, 0, "Id:");
infoFlexTable.setWidget(0, 1, typeId);
typeDescription = new TextBox();
typeDescription.setReadOnly(true);
infoFlexTable.setHTML(1, 0, "Descr.:");
infoFlexTable.setWidget(1, 1, typeDescription);
typeVersion = new TextBox();
typeVersion.setReadOnly(true);
infoFlexTable.setHTML(2, 0, "Version:");
infoFlexTable.setWidget(2, 1, typeVersion);
infoFlexTable.getFlexCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);
infoFlexTable.setHTML(3, 0, "Glob.Attrs:");
globalAttributesPager.getElement().getStyle().setProperty("margin", "auto");
VerticalPanel vp = new VerticalPanel();
vp.getElement().getStyle().setBackgroundColor("#f8f8fb");
vp.add(globalAttributesDataGrid);
vp.add(globalAttributesPager);
infoFlexTable.setWidget(3, 1, vp);
setWidget(infoFlexTable);
}
@Override
public void onNetCDFDataReady(NetCDFDataEvent event) {
NetCDFDetailData detail = event.getNetCDFData().getDetail();
// info.setValue(detail.getInfo());
// title.setValue(detail.getTitle());
typeId.setValue(detail.getTypeId());
typeDescription.setValue(detail.getTypeDescription());
typeVersion.setValue(detail.getTypeVersion());
// Add the CellList to the adapter in the database.
netCDFDataModel.addGlobalAttributeDataDisplay(globalAttributesDataGrid);
netCDFDataModel.refreshGlobalAttributeDisplays();
}
private void createGrid() {
/*
* Set a key provider that provides a unique key for each contact. If
* key is used to identify contacts when fields (such as the name and
* address) change.
*/
globalAttributesDataGrid = new DataGrid<AttributeData>(7, AttributeData.KEY_PROVIDER);
globalAttributesDataGrid.setWidth(DATA_GRID_WIDTH);
globalAttributesDataGrid.setHeight(DATA_GRID_HEIGHT);
/*
* Do not refresh the headers every time the data is updated. The footer
* depends on the current data, so we do not disable auto refresh on the
* footer.
*/
globalAttributesDataGrid.setAutoHeaderRefreshDisabled(true);
// Set the message to display when the table is empty.
globalAttributesDataGrid.setEmptyTableWidget(new Label(messages.dataGridGlobalAttributeEmpty()));
// Attach a column sort handler to the ListDataProvider to sort the
// list.
ListHandler<AttributeData> sortHandler = new ListHandler<AttributeData>(
netCDFDataModel.getGlobalAttributeDataProvider().getList());
globalAttributesDataGrid.addColumnSortHandler(sortHandler);
// Create a Pager to control the table.
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
globalAttributesPager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
globalAttributesPager.setDisplay(globalAttributesDataGrid);
// Add a selection model so we can select cells.
final MultiSelectionModel<AttributeData> selectionModel = new MultiSelectionModel<AttributeData>(
AttributeData.KEY_PROVIDER);
globalAttributesDataGrid.setSelectionModel(selectionModel,
DefaultSelectionEventManager.<AttributeData>createCheckboxManager());
// Initialize the columns.
initTableColumns(selectionModel, sortHandler);
}
public void refresh() {
globalAttributesDataGrid.redraw();
}
private void initTableColumns(SelectionModel<AttributeData> selectionModel,
ListHandler<AttributeData> sortHandler) {
// Checkbox column. This table will uses a checkbox column for
// selection.
// Alternatively, you can call dataGrid.setSelectionEnabled(true) to
// enable
// mouse selection.
/*
* Column<VariableData, Boolean> checkColumn = new Column<VariableData,
* Boolean>(new CheckboxCell(true, false)) {
*
* @Override public Boolean getValue(VariableData object) { // Get the
* value from the selection model. return
* selectionModel.isSelected(object); } };
* dataGrid.addColumn(checkColumn,
* SafeHtmlUtils.fromSafeConstant("<br/>"));
* dataGrid.setColumnWidth(checkColumn, 40, Unit.PX);
*/
// Fullname
Column<AttributeData, String> fullnameColum = new Column<AttributeData, String>(new TextCell()) {
@Override
public String getValue(AttributeData object) {
return object.getFullName();
}
};
fullnameColum.setSortable(true);
sortHandler.setComparator(fullnameColum, new Comparator<AttributeData>() {
@Override
public int compare(AttributeData o1, AttributeData o2) {
return o1.getFullName().compareTo(o2.getFullName());
}
});
globalAttributesDataGrid.addColumn(fullnameColum, messages.columnFullname());
globalAttributesDataGrid.setColumnWidth(fullnameColum, 130, Unit.PX);
// DataType
Column<AttributeData, String> dataTypeColumn = new Column<AttributeData, String>(new TextCell()) {
@Override
public String getValue(AttributeData object) {
return object.getDataType();
}
};
dataTypeColumn.setSortable(true);
sortHandler.setComparator(dataTypeColumn, new Comparator<AttributeData>() {
@Override
public int compare(AttributeData o1, AttributeData o2) {
return o1.getDataType().compareTo(o2.getDataType());
}
});
globalAttributesDataGrid.addColumn(dataTypeColumn, messages.columnDataType());
globalAttributesDataGrid.setColumnWidth(dataTypeColumn, 80, Unit.PX);
// Values
Column<AttributeData, String> valuesColumn = new Column<AttributeData, String>(new TextCell()) {
@Override
public String getValue(AttributeData object) {
return String.valueOf(object.getValues());
}
};
valuesColumn.setSortable(true);
sortHandler.setComparator(valuesColumn, new Comparator<AttributeData>() {
@Override
public int compare(AttributeData o1, AttributeData o2) {
return o1.getValues().compareTo(o2.getValues());
}
});
globalAttributesDataGrid.addColumn(valuesColumn, messages.columnValue());
// dataGrid.setColumnWidth(valuesColumn, 40, Unit.PX);
}
public Set<AttributeData> seleceted() {
@SuppressWarnings("unchecked")
Set<AttributeData> selected = ((MultiSelectionModel<AttributeData>) globalAttributesDataGrid
.getSelectionModel()).getSelectedSet();
return selected;
}
}

View File

@ -0,0 +1,323 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets;
import java.util.ArrayList;
import java.util.Set;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEventType;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.resource.NetCDFBasicResources;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.util.GWTMessages;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.TabLayoutPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEvent.HasSelectVariableEventHandler {
private static final String TABPANEL_HEIGHT = "400px";
private static final String TABPANEL_WIDTH = "700px";
private static final NetCDFPreviewMessages messages = GWT.create(NetCDFPreviewMessages.class);
private HandlerRegistration resizeHandlerRegistration;
private Node closeEventTarget = null;
private int zIndex = -1;
private NetCDFDataModel netCDFDataModel;
private VariablesPanel variablesPanel;
private DetailPanel detailPanel;
private SamplePanel samplePanel;
private InfoPanel infoPanel;
//private DataGrid<VariableData> dataGrid;
public NetCDFPreviewDialog() {
try {
initWindow();
initHandler();
addToolIcon();
create();
} catch (Throwable e) {
GWT.log(e.getLocalizedMessage());
e.printStackTrace();
}
}
public NetCDFPreviewDialog(String fileId) {
try {
GWT.log("FileId: " + fileId);
initWindow();
initHandler();
addToolIcon();
create();
} catch (Throwable e) {
GWT.log(e.getLocalizedMessage());
e.printStackTrace();
}
}
private void initWindow() {
GWT.log(messages.dialogTitle());
NetCDFBasicResources.INSTANCE.olBasicCSS().ensureInjected();
setModal(true);
setGlassEnabled(true);
setAnimationEnabled(true);
setText(messages.dialogTitle());
//setHeight(DIALOG_HEIGHT);
//setWidth(DIALOG_WIDTH);
}
private void initHandler() {
resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
center();
}
});
}
private void create() {
netCDFDataModel = new NetCDFDataModel();
// Create a tab panel
TabLayoutPanel tabPanel = new TabLayoutPanel(2.5, Unit.EM);
tabPanel.setAnimationDuration(1000);
tabPanel.setAnimationVertical(true);
tabPanel.getElement().getStyle().setMarginBottom(10.0, Unit.PX);
tabPanel.setHeight(TABPANEL_HEIGHT);
tabPanel.setWidth(TABPANEL_WIDTH);
//Variable TabPanel
variablesPanel = new VariablesPanel(netCDFDataModel);
tabPanel.add(variablesPanel, messages.variablesTab());
//Detail TabPanel
detailPanel = new DetailPanel(netCDFDataModel);
tabPanel.add(detailPanel, messages.detailTab());
//Sample TabPanel
samplePanel = new SamplePanel(netCDFDataModel);
tabPanel.add(samplePanel, messages.sampleTab());
//Info TabPanel
infoPanel = new InfoPanel(netCDFDataModel);
tabPanel.add(infoPanel, messages.infoTab());
// Return the content
tabPanel.selectTab(0);
tabPanel.ensureDebugId("netcdfTabPanel");
tabPanel.addSelectionHandler(new SelectionHandler<Integer>()
{
public void onSelection(SelectionEvent<Integer> event)
{
int tabId = event.getSelectedItem();
Widget tabWidget = tabPanel.getWidget(tabId);
if (tabWidget != null)
{
if(tabWidget instanceof VariablesPanel){
VariablesPanel variablesPanel=(VariablesPanel)tabWidget;
variablesPanel.refresh();
} else {
if(tabWidget instanceof DetailPanel){
DetailPanel detailPanel=(DetailPanel)tabWidget;
detailPanel.refresh();
} else {
if(tabWidget instanceof InfoPanel){
InfoPanel infoPanel=(InfoPanel)tabWidget;
infoPanel.refresh();
} else {
}
}
}
}
}
});
// Create a table to layout the content
//VerticalPanel dialogContents = new VerticalPanel();
//dialogContents.setSpacing(4);
//dialogContents.add(tabPanel);
// Add Button
Button btnSave = new Button("Save");
btnSave.getElement().getStyle().setMarginLeft(4, Unit.PX);
btnSave.getElement().getStyle().setMarginRight(4, Unit.PX);
btnSave.setTabIndex(10003);
btnSave.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
btnSavePressed();
}
});
Button btnClose = new Button("Close");
btnClose.getElement().getStyle().setMarginLeft(4, Unit.PX);
btnClose.getElement().getStyle().setMarginRight(4, Unit.PX);
btnClose.setTabIndex(10004);
btnClose.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
btnClosePressed();
}
});
FlowPanel buttonPack = new FlowPanel();
buttonPack.setWidth("100%");
//buttonPack.add(btnSave);
buttonPack.add(btnClose);
/*HorizontalPanel hp=new HorizontalPanel();
hp.add(buttonPack);
hp.setCellHorizontalAlignment(buttonPack, HasHorizontalAlignment.ALIGN_CENTER);
*/
DockPanel dockPanel = new DockPanel();
dockPanel.setSpacing(4);
dockPanel.add(tabPanel, DockPanel.CENTER);
dockPanel.add(buttonPack, DockPanel.SOUTH);
dockPanel.setCellHorizontalAlignment(buttonPack,DockPanel.ALIGN_CENTER);
dockPanel.setWidth("100%");
setWidget(dockPanel);
center();
}
@Override
public void show() {
super.show();
center();
};
private void closeOnServer(){
if(netCDFDataModel!=null){
netCDFDataModel.close();
}
}
private void btnClosePressed() {
SelectVariableEvent event = new SelectVariableEvent(SelectVariableEventType.Aborted);
fireEvent(event);
hide();
}
private void btnSavePressed() {
Set<VariableData> selected=variablesPanel.seleceted();
if (selected == null || selected.isEmpty()) {
GWTMessages.alert("Attention", "Select a layer!", zIndex);
} else {
SelectVariableEvent event = new SelectVariableEvent(SelectVariableEventType.Completed);
event.setVariables(new ArrayList<VariableData>(selected));
fireEvent(event);
hide();
}
}
private void addToolIcon() {
// get the "dialogTopRight" class td
Element dialogTopRight = getCellElement(0, 2);
// close button image html
dialogTopRight.setInnerHTML("<div class='"
+ NetCDFBasicResources.INSTANCE.olBasicCSS().getDialogToolButtonText() + "'>" + "<img src='"
+ NetCDFBasicResources.INSTANCE.toolButtonClose20().getSafeUri().asString() + "' class='"
+ NetCDFBasicResources.INSTANCE.olBasicCSS().getDialogToolButtonIcon() + "' /></div>");
// set the event target
closeEventTarget = dialogTopRight.getChild(0).getChild(0);
}
@Override
public void hide() {
closeOnServer();
if (resizeHandlerRegistration != null) {
resizeHandlerRegistration.removeHandler();
resizeHandlerRegistration = null;
}
super.hide();
}
@Override
protected void onPreviewNativeEvent(NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (!event.isCanceled() && (event.getTypeInt() == Event.ONCLICK) && isCloseEvent(nativeEvent)) {
final SelectVariableEvent selectVariableEvent = new SelectVariableEvent(SelectVariableEventType.Aborted);
fireEvent(selectVariableEvent);
this.hide();
}
super.onPreviewNativeEvent(event);
}
// see if the click target is the close button
private boolean isCloseEvent(NativeEvent event) {
return event.getEventTarget().equals(closeEventTarget); // compares
// equality of
// the
// underlying
// DOM elements
}
@Override
public HandlerRegistration addSelectVariableEventHandler(SelectVariableEvent.SelectVariableEventHandler handler) {
return addHandler(handler, SelectVariableEvent.getType());
}
public void setZIndex(int zIndex) {
this.zIndex = zIndex;
getGlassElement().getStyle().setZIndex(zIndex);
getElement().getStyle().setZIndex(zIndex + 1);
}
public int getZIndex() {
return zIndex;
}
}

View File

@ -0,0 +1,118 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets;
import com.google.gwt.i18n.client.Messages;
/**
*
* @author Giancarlo Panichi
*
*
*/
public interface NetCDFPreviewMessages extends Messages {
@DefaultMessage("NetCDF Preview")
String dialogTitle();
@DefaultMessage("Variables")
String variablesTab();
@DefaultMessage("Detail")
String detailTab();
@DefaultMessage("Sample")
String sampleTab();
@DefaultMessage("Info")
String infoTab();
// Variable
@DefaultMessage("Name")
String columnFullname();
@DefaultMessage("Units")
String columnUnits();
@DefaultMessage("DataType")
String columnDataType();
@DefaultMessage("Dimensions")
String columnDimensionString();
@DefaultMessage("Rank")
String columnRank();
@DefaultMessage("Coord.")
String columnCoordinateVariable();
@DefaultMessage("Scalar")
String columnScalar();
@DefaultMessage("Immutable")
String columnImmutable();
@DefaultMessage("Unlimited")
String columnUnlimited();
@DefaultMessage("Unsigned")
String columnUnsigned();
@DefaultMessage("VLenght")
String columnVariableLenght();
@DefaultMessage("Member")
String columnMemberOfStructure();
@DefaultMessage("Value")
String columnValue();
// Range
@DefaultMessage("Name")
String columnName();
@DefaultMessage("N")
String columnN();
@DefaultMessage("First")
String columnFirst();
@DefaultMessage("Stride")
String columnStride();
//Table
@DefaultMessage("List of variables in nectdf file")
String dataGridVariablesDescription();
@DefaultMessage("No Variable")
String dataGridVariablesEmpty();
@DefaultMessage("NetCDF Variables")
String dataGridVariablesName();
@DefaultMessage("List of global attributes in nectdf file")
String dataGridGlobalAttributeDescription();
@DefaultMessage("No Global Attribute")
String dataGridGlobalAttributeEmpty();
@DefaultMessage("NetCDF Global Attributes")
String dataGridGlobalAttributeName();
@DefaultMessage("List of attributes of variable")
String dataGridAttributeOfVariableDescription();
@DefaultMessage("No Attribute")
String dataGridAttributeOfVariableEmpty();
@DefaultMessage("Attributes")
String dataGridAttributeOfVariableName();
@DefaultMessage("List of range of variable")
String dataGridRangeOfVariableDescription();
@DefaultMessage("No Range")
String dataGridRangeOfVariableEmpty();
@DefaultMessage("Ranges")
String dataGridRangeOfVariableName();
}

View File

@ -0,0 +1,60 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets;
import java.util.Arrays;
import java.util.List;
/**
*
* @author Giancarlo Panichi
*
*
*/
public enum OpenLayerFormatType {
GML("GML"), GeoJSON("GeoJSON"), WKT("WKT");
/**
*
* @param label label
*/
private OpenLayerFormatType(final String label) {
this.label = label;
}
private final String label;
@Override
public String toString() {
return label;
}
public String getLabel() {
return label;
}
public String getId() {
return name();
}
/**
*
* @param label label
* @return open layer format type
*/
public static OpenLayerFormatType getFromLabel(String label) {
if (label == null || label.isEmpty())
return null;
for (OpenLayerFormatType type : values()) {
if (type.label.compareToIgnoreCase(label) == 0) {
return type;
}
}
return null;
}
public static List<OpenLayerFormatType> asList() {
List<OpenLayerFormatType> list = Arrays.asList(values());
return list;
}
}

View File

@ -0,0 +1,116 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets;
import java.util.ArrayList;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SampleVariableDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SampleVariableDataEvent.SampleVariableDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.TextArea;
public class SamplePanel extends SimplePanel implements NetCDFDataEventHandler {
private static final String HEIGHT = "350px";
private static final String WIDTH = "700px";
private NetCDFDataModel netCDFDataModel;
private ListBox variablesBox;
private TextArea sampleData;
private ArrayList<VariableData> variables;
public SamplePanel(NetCDFDataModel netCDFDataModel) {
this.netCDFDataModel = netCDFDataModel;
init();
create();
}
private void init() {
setHeight(HEIGHT);
setWidth(WIDTH);
}
private void create() {
netCDFDataModel.addNetCDFDataEventHandler(this);
// ////////
// Form
FlexTable sampleFlexTable = new FlexTable();
sampleFlexTable.setCellSpacing(2);
// Add a drop box with the list types
variablesBox = new ListBox();
variablesBox.setEnabled(false);
variablesBox.ensureDebugId("samplePanelVariablesBox");
variablesBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
sampleData.setValue("");
retrieveSample(variablesBox.getSelectedValue());
}
});
sampleFlexTable.setHTML(0, 0, "Variable:");
sampleFlexTable.setWidget(0, 1, variablesBox);
sampleData = new TextArea();
sampleData.setWidth("616px");
sampleData.setHeight("318px");
sampleData.getElement().setPropertyString("resize", "none");
sampleData.setReadOnly(true);
sampleFlexTable.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
sampleFlexTable.setHTML(1, 0, "Sample:");
sampleFlexTable.setWidget(1, 1, sampleData);
setWidget(sampleFlexTable);
}
private void retrieveSample(String selectedValue) {
VariableData variableRequested = null;
if (Integer.valueOf(selectedValue) != -1) {
for (VariableData variableData : variables) {
if (variableData.getId() == Integer.valueOf(selectedValue)) {
variableRequested = variableData;
break;
}
}
if (variableRequested != null) {
SampleVariableDataEventHandler handler = new SampleVariableDataEventHandler() {
@Override
public void onSample(SampleVariableDataEvent event) {
sampleData.setValue(event.getSampleValues().getArrayData().asString());
}
};
netCDFDataModel.retrieveSampleOfVariable(handler, variableRequested);
}
}
}
@Override
public void onNetCDFDataReady(NetCDFDataEvent event) {
variables = event.getNetCDFData().getVariables();
variablesBox.clear();
variablesBox.addItem(" ", "-1");
for (VariableData varData : variables) {
variablesBox.addItem(varData.getFullName(), String.valueOf(varData.getId()));
}
variablesBox.setEnabled(true);
}
}

View File

@ -0,0 +1,394 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets;
import java.util.Comparator;
import java.util.Set;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.resource.NetCDFBasicResources;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import com.google.gwt.cell.client.CheckboxCell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.view.client.DefaultSelectionEventManager;
import com.google.gwt.view.client.MultiSelectionModel;
import com.google.gwt.view.client.SelectionModel;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class VariablesPanel extends SimplePanel implements NetCDFDataEventHandler {
private static final String DATA_GRID_HEIGHT = "300px";
private static final String DATA_GRID_WIDTH = "700px";
private final NetCDFPreviewMessages messages = GWT.create(NetCDFPreviewMessages.class);
private NetCDFDataModel netCDFDataModel;
private DataGrid<VariableData> variablesDataGrid;
private SimplePager variablesDataPager;
public VariablesPanel(NetCDFDataModel netCDFDataModel) {
this.netCDFDataModel = netCDFDataModel;
create();
}
private void create() {
netCDFDataModel.addNetCDFDataEventHandler(this);
setStyleName(NetCDFBasicResources.INSTANCE.olBasicCSS().getAreaSelectionPanel());
createGrid();
// ////////
// Form
FlexTable layout = new FlexTable();
layout.setCellSpacing(10);
FlexTable netCDFPreviewFlexTable = new FlexTable();
// netCDFPreviewFlexTable.setStyleName(NetCDFBasicResources.INSTANCE.olBasicCSS().getAreaSelectionContent());
netCDFPreviewFlexTable.setCellSpacing(2);
netCDFPreviewFlexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
netCDFPreviewFlexTable.setWidget(0, 0, variablesDataGrid);
netCDFPreviewFlexTable.getFlexCellFormatter().setColSpan(1, 0, 2);
variablesDataPager.getElement().getStyle().setProperty("margin", "auto");
netCDFPreviewFlexTable.setWidget(1, 0, variablesDataPager);
setWidget(netCDFPreviewFlexTable);
}
@Override
public void onNetCDFDataReady(NetCDFDataEvent event) {
// Add the CellList to the adapter in the database.
netCDFDataModel.addVariableDataDisplay(variablesDataGrid);
netCDFDataModel.refreshVariableDisplays();
}
private void createGrid() {
/*
* Set a key provider that provides a unique key for each contact. If
* key is used to identify contacts when fields (such as the name and
* address) change.
*/
variablesDataGrid = new DataGrid<VariableData>(10, VariableData.KEY_PROVIDER);
variablesDataGrid.setWidth(DATA_GRID_WIDTH);
variablesDataGrid.setHeight(DATA_GRID_HEIGHT);
/*
* Do not refresh the headers every time the data is updated. The footer
* depends on the current data, so we do not disable auto refresh on the
* footer.
*/
variablesDataGrid.setAutoHeaderRefreshDisabled(true);
// Set the message to display when the table is empty.
variablesDataGrid.setEmptyTableWidget(new Label(messages.dataGridVariablesEmpty()));
// Attach a column sort handler to the ListDataProvider to sort the
// list.
ListHandler<VariableData> sortHandler = new ListHandler<VariableData>(
netCDFDataModel.getVariableDataProvider().getList());
variablesDataGrid.addColumnSortHandler(sortHandler);
// Create a Pager to control the table.
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
variablesDataPager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
variablesDataPager.setDisplay(variablesDataGrid);
// Add a selection model so we can select cells.
final MultiSelectionModel<VariableData> selectionModel = new MultiSelectionModel<VariableData>(
VariableData.KEY_PROVIDER);
variablesDataGrid.setSelectionModel(selectionModel, DefaultSelectionEventManager.<VariableData>createCheckboxManager());
// Initialize the columns.
initTableColumns(selectionModel, sortHandler);
}
public void refresh(){
variablesDataGrid.redraw();
}
private void initTableColumns(SelectionModel<VariableData> selectionModel, ListHandler<VariableData> sortHandler) {
// Checkbox column. This table will uses a checkbox column for
// selection.
// Alternatively, you can call dataGrid.setSelectionEnabled(true) to
// enable
// mouse selection.
/*
* Column<VariableData, Boolean> checkColumn = new Column<VariableData,
* Boolean>(new CheckboxCell(true, false)) {
*
* @Override public Boolean getValue(VariableData object) { // Get the
* value from the selection model. return
* selectionModel.isSelected(object); } };
* dataGrid.addColumn(checkColumn,
* SafeHtmlUtils.fromSafeConstant("<br/>"));
* dataGrid.setColumnWidth(checkColumn, 40, Unit.PX);
*/
// Fullname
Column<VariableData, String> fullnameColum = new Column<VariableData, String>(new TextCell()) {
@Override
public String getValue(VariableData object) {
return object.getFullName();
}
};
fullnameColum.setSortable(true);
sortHandler.setComparator(fullnameColum, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return o1.getFullName().compareTo(o2.getFullName());
}
});
variablesDataGrid.addColumn(fullnameColum, messages.columnFullname());
variablesDataGrid.setColumnWidth(fullnameColum, 200, Unit.PX);
// Units
Column<VariableData, String> unitsColumn = new Column<VariableData, String>(new TextCell()) {
@Override
public String getValue(VariableData object) {
return object.getUnits();
}
};
unitsColumn.setSortable(true);
sortHandler.setComparator(unitsColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
if (o1.getUnits() == null) {
return -1;
} else {
if (o2.getUnits() == null) {
return 1;
} else {
return o1.getUnits().compareTo(o2.getUnits());
}
}
}
});
variablesDataGrid.addColumn(unitsColumn, messages.columnUnits());
variablesDataGrid.setColumnWidth(unitsColumn, 160, Unit.PX);
// DataType
Column<VariableData, String> dataTypeColumn = new Column<VariableData, String>(new TextCell()) {
@Override
public String getValue(VariableData object) {
return object.getDataType();
}
};
dataTypeColumn.setSortable(true);
sortHandler.setComparator(dataTypeColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return o1.getDataType().compareTo(o2.getDataType());
}
});
variablesDataGrid.addColumn(dataTypeColumn, messages.columnDataType());
variablesDataGrid.setColumnWidth(dataTypeColumn, 100, Unit.PX);
// Dimensions
Column<VariableData, String> dimensionsColumn = new Column<VariableData, String>(new TextCell()) {
@Override
public String getValue(VariableData object) {
return object.getDimensionString();
}
};
dimensionsColumn.setSortable(true);
sortHandler.setComparator(dimensionsColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return o1.getDimensionString().compareTo(o2.getDimensionString());
}
});
variablesDataGrid.addColumn(dimensionsColumn, messages.columnDimensionString());
variablesDataGrid.setColumnWidth(dimensionsColumn, 160, Unit.PX);
// Rank
Column<VariableData, String> rankColumn = new Column<VariableData, String>(new TextCell()) {
@Override
public String getValue(VariableData object) {
return String.valueOf(object.getRank());
}
};
rankColumn.setSortable(true);
sortHandler.setComparator(rankColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return (o1.getRank() < o2.getRank()) ? -1 : ((o1.getRank() == o2.getRank()) ? 0 : 1);
}
});
variablesDataGrid.addColumn(rankColumn, messages.columnRank());
variablesDataGrid.setColumnWidth(rankColumn, 80, Unit.PX);
// Coordinate
Column<VariableData, Boolean> coordinateColumn = new Column<VariableData, Boolean>(
new CheckboxCell(true, false)) {
@Override
public Boolean getValue(VariableData object) {
return object.isCoordinateVariable();
}
};
coordinateColumn.setSortable(true);
sortHandler.setComparator(coordinateColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return (o1.isCoordinateVariable() == o2.isCoordinateVariable()) ? 0
: (o1.isCoordinateVariable() ? 1 : -1);
}
});
variablesDataGrid.addColumn(coordinateColumn, messages.columnCoordinateVariable());
variablesDataGrid.setColumnWidth(coordinateColumn, 80, Unit.PX);
// Scalar
Column<VariableData, Boolean> scalarColumn = new Column<VariableData, Boolean>(new CheckboxCell(true, false)) {
@Override
public Boolean getValue(VariableData object) {
return object.isScalar();
}
};
scalarColumn.setSortable(true);
sortHandler.setComparator(scalarColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return (o1.isScalar() == o2.isScalar()) ? 0 : (o1.isScalar() ? 1 : -1);
}
});
variablesDataGrid.addColumn(scalarColumn, messages.columnScalar());
variablesDataGrid.setColumnWidth(scalarColumn, 80, Unit.PX);
// Immutable
Column<VariableData, Boolean> immutableColumn = new Column<VariableData, Boolean>(
new CheckboxCell(true, false)) {
@Override
public Boolean getValue(VariableData object) {
return object.isImmutable();
}
};
immutableColumn.setSortable(true);
sortHandler.setComparator(immutableColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return (o1.isImmutable() == o2.isImmutable()) ? 0 : (o1.isImmutable() ? 1 : -1);
}
});
variablesDataGrid.addColumn(immutableColumn, messages.columnImmutable());
variablesDataGrid.setColumnWidth(immutableColumn, 110, Unit.PX);
// Unlimited
Column<VariableData, Boolean> unlimitedColumn = new Column<VariableData, Boolean>(
new CheckboxCell(true, false)) {
@Override
public Boolean getValue(VariableData object) {
return object.isUnlimited();
}
};
unlimitedColumn.setSortable(true);
sortHandler.setComparator(unlimitedColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return (o1.isUnlimited() == o2.isUnlimited()) ? 0 : (o1.isUnlimited() ? 1 : -1);
}
});
variablesDataGrid.addColumn(unlimitedColumn, messages.columnUnlimited());
variablesDataGrid.setColumnWidth(unlimitedColumn, 110, Unit.PX);
// Unsigned
Column<VariableData, Boolean> unsignedColumn = new Column<VariableData, Boolean>(
new CheckboxCell(true, false)) {
@Override
public Boolean getValue(VariableData object) {
return object.isUnsigned();
}
};
unsignedColumn.setSortable(true);
sortHandler.setComparator(unsignedColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return (o1.isUnsigned() == o2.isUnsigned()) ? 0 : (o1.isUnsigned() ? 1 : -1);
}
});
variablesDataGrid.addColumn(unsignedColumn, messages.columnUnsigned());
variablesDataGrid.setColumnWidth(unsignedColumn, 110, Unit.PX);
// VariableLenght
Column<VariableData, Boolean> variableLenghtColumn = new Column<VariableData, Boolean>(
new CheckboxCell(true, false)) {
@Override
public Boolean getValue(VariableData object) {
return object.isVariableLength();
}
};
variableLenghtColumn.setSortable(true);
sortHandler.setComparator(variableLenghtColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return (o1.isVariableLength() == o2.isVariableLength()) ? 0 : (o1.isVariableLength() ? 1 : -1);
}
});
variablesDataGrid.addColumn(variableLenghtColumn, messages.columnVariableLenght());
variablesDataGrid.setColumnWidth(variableLenghtColumn, 110, Unit.PX);
// Member
Column<VariableData, Boolean> memberColumn = new Column<VariableData, Boolean>(new CheckboxCell(true, false)) {
@Override
public Boolean getValue(VariableData object) {
return object.isMemberOfStructure();
}
};
memberColumn.setSortable(true);
sortHandler.setComparator(memberColumn, new Comparator<VariableData>() {
@Override
public int compare(VariableData o1, VariableData o2) {
return (o1.isMemberOfStructure() == o2.isMemberOfStructure()) ? 0 : (o1.isMemberOfStructure() ? 1 : -1);
}
});
variablesDataGrid.addColumn(memberColumn, messages.columnMemberOfStructure());
variablesDataGrid.setColumnWidth(memberColumn, 90, Unit.PX);
}
public Set<VariableData> seleceted() {
@SuppressWarnings("unchecked")
Set<VariableData> selected = ((MultiSelectionModel<VariableData>) variablesDataGrid.getSelectionModel())
.getSelectedSet();
return selected;
}
}

View File

@ -0,0 +1,145 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server;
import java.net.MalformedURLException;
import java.net.URL;
import javax.servlet.ServletException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.rpc.NetCDFBasicWidgetService;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.NetCDFResource;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.util.ServiceCredentials;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.exception.ServiceException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFId;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.session.UserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
*
* @author Giancarlo Panichi
*
*
*/
@SuppressWarnings("serial")
public class NetCDFBasicWidgetServiceImpl extends RemoteServiceServlet implements NetCDFBasicWidgetService {
private static Logger logger = LoggerFactory.getLogger(NetCDFBasicWidgetServiceImpl.class);
/**
* {@inheritDoc}
*/
@Override
public void init() throws ServletException {
super.init();
logger.info("NetCDFBasicWidgetService started!");
}
@Override
public UserInfo hello() throws ServiceException {
try {
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("hello()");
UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(), serviceCredentials.getGroupId(),
serviceCredentials.getGroupName(), serviceCredentials.getScope(), serviceCredentials.getEmail(),
serviceCredentials.getFullName());
logger.debug("UserInfo: " + userInfo);
return userInfo;
} catch (ServiceException e) {
e.printStackTrace();
throw e;
} catch (Throwable e) {
logger.error("Error in hello(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public NetCDFData getNetCDFFromPublicLink(String publicLink) throws ServiceException {
try {
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
URL url;
try {
url = new URL(publicLink);
} catch (MalformedURLException e) {
logger.error(e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
NetCDFResource netCDFResource = new NetCDFResource(url);
NetCDFData netCDFData = netCDFResource.exploreNetCDF();
SessionUtil.setNetCDFData(netCDFData, this.getThreadLocalRequest(), serviceCredentials);
return netCDFData;
} catch (ServiceException e) {
logger.error("Error in getCDFResourceFromPublicLink(): " + e.getLocalizedMessage(), e);
throw e;
} catch (Exception e) {
logger.error("Error in getCDFResourceFromPublicLink(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public NetCDFData getNetCDFFromItem(String itemId) throws ServiceException {
try {
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
NetCDFResource netCDFResource = new NetCDFResource();
NetCDFData netCDFData = netCDFResource.exploreNetCDF();
SessionUtil.setNetCDFData(netCDFData, this.getThreadLocalRequest(), serviceCredentials);
return netCDFData;
} catch (ServiceException e) {
logger.error("Error in getCDFResourceFromItem(): " + e.getLocalizedMessage(), e);
throw e;
} catch (Exception e) {
logger.error("Error in getCDFResourceFromItem(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public NetCDFValues readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit)
throws ServiceException {
try {
ServiceCredentials serviceCredentials=SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
SessionUtil.getNetCDFData(netCDFId, this.getThreadLocalRequest(), serviceCredentials);
NetCDFResource netCDFResource = new NetCDFResource(netCDFId);
NetCDFValues netCDFValues = netCDFResource.readDataVariable(variableData, sample, limit);
return netCDFValues;
} catch (ServiceException e) {
logger.error("Error in getCDFResourceFromItem(): " + e.getLocalizedMessage(), e);
throw e;
} catch (Exception e) {
logger.error("Error in getCDFResourceFromItem(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public void closeNetCDF(NetCDFId netCDFId) throws ServiceException {
try {
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
SessionUtil.getNetCDFData(netCDFId, this.getThreadLocalRequest(),
serviceCredentials);
NetCDFResource netCDFResource = new NetCDFResource(netCDFId);
netCDFResource.close();
SessionUtil.removeNetCDFData(netCDFId, this.getThreadLocalRequest(), serviceCredentials);
} catch (ServiceException e) {
logger.error("Error in closeNetCDF(): " + e.getLocalizedMessage(), e);
throw e;
} catch (Exception e) {
logger.error("Error in closeNetCDF(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,295 @@
/**
*
*/
package org.gcube.portlets.widgets.netcdfbasicwidgets.server;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.util.ServiceCredentials;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.Constants;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.exception.ServiceException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFId;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SessionUtil {
private static final Logger logger = Logger.getLogger(SessionUtil.class);
/**
*
* @param httpServletRequest
* http servlet request
* @return service credentials
* @throws ServiceException
* service exception
*/
public static ServiceCredentials getServiceCredentials(HttpServletRequest httpServletRequest)
throws ServiceException {
return getServiceCredentials(httpServletRequest, null);
}
/**
*
* @param httpServletRequest
* http servlet request
* @param scopeGroupId
* scope group id
* @return service credentials
* @throws ServiceException
* service exception
*/
public static ServiceCredentials getServiceCredentials(HttpServletRequest httpServletRequest, String scopeGroupId)
throws ServiceException {
ServiceCredentials sCredentials = null;
String userName = null;
String scope = null;
String token = null;
String groupId = null;
String groupName = null;
if (Constants.DEBUG_MODE) {
logger.debug("No credential found in session, use test user!");
/*
* InfoLocale infoLocale = getInfoLocale(httpServletRequest, null);
* Locale locale = new Locale(infoLocale.getLanguage());
*
* ResourceBundle messages = ResourceBundle.getBundle(
* StatAlgoImporterServiceMessagesConstants.TDGWTServiceMessages,
* locale);
*/
userName = Constants.DEFAULT_USER;
scope = Constants.DEFAULT_SCOPE;
token = Constants.DEFAULT_TOKEN;
logger.debug("Set SecurityToken: " + token);
SecurityTokenProvider.instance.set(token);
logger.debug("Set ScopeProvider: " + scope);
ScopeProvider.instance.set(scope);
sCredentials = new ServiceCredentials(userName, scope, token);
} else {
logger.debug("Retrieving credential in session!");
PortalContext pContext = PortalContext.getConfiguration();
boolean hasScopeGroupId = false;
if (scopeGroupId != null && !scopeGroupId.isEmpty()) {
hasScopeGroupId = true;
} else {
hasScopeGroupId = false;
}
if (hasScopeGroupId) {
scope = pContext.getCurrentScope(scopeGroupId);
} else {
scope = pContext.getCurrentScope(httpServletRequest);
}
if (scope == null || scope.isEmpty()) {
String error = "Error retrieving scope: " + scope;
logger.error(error);
throw new ServiceException(error);
}
GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest);
if (gCubeUser == null) {
String error = "Error retrieving gCubeUser in scope " + scope + ": " + gCubeUser;
logger.error(error);
throw new ServiceException(error);
}
userName = gCubeUser.getUsername();
if (userName == null || userName.isEmpty()) {
String error = "Error retrieving username in scope " + scope + ": " + userName;
logger.error(error);
throw new ServiceException(error);
}
token = pContext.getCurrentUserToken(scope, userName);
if (token == null || token.isEmpty()) {
String error = "Error retrieving token for " + userName + " in " + scope + ": " + token;
logger.error(error);
throw new ServiceException(error);
}
String name = gCubeUser.getFirstName();
String lastName = gCubeUser.getLastName();
String fullName = gCubeUser.getFullname();
String userAvatarURL = gCubeUser.getUserAvatarURL();
String email = gCubeUser.getEmail();
if (hasScopeGroupId) {
logger.debug("Set SecurityToken: " + token);
SecurityTokenProvider.instance.set(token);
logger.debug("Set ScopeProvider: " + scope);
ScopeProvider.instance.set(scope);
groupId = scopeGroupId;
long gId;
try {
gId = Long.parseLong(scopeGroupId);
} catch (Throwable e) {
String error = "Error retrieving groupId: " + scopeGroupId;
logger.error(error, e);
throw new ServiceException(error);
}
GCubeGroup group;
try {
group = new LiferayGroupManager().getGroup(gId);
} catch (Throwable e) {
String error = "Error retrieving group: " + groupName;
logger.error(error);
throw new ServiceException(error);
}
groupName = group.getGroupName();
} else {
groupId = String.valueOf(pContext.getCurrentGroupId(httpServletRequest));
groupName = pContext.getCurrentGroupName(httpServletRequest);
}
sCredentials = new ServiceCredentials(userName, fullName, name, lastName, email, scope, groupId, groupName,
userAvatarURL, token);
}
logger.debug("ServiceCredentials: " + sCredentials);
return sCredentials;
}
public static void setNetCDFData(NetCDFData netCDFData, HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) throws ServiceException {
if (serviceCredentials == null) {
logger.error("ServiceCredentials is null!");
throw new ServiceException("Service Credentials is null!");
}
HttpSession session = httpRequest.getSession();
Object obj = session.getAttribute(Constants.NETCDF_DATA_MAP);
if (obj == null) {
logger.debug("Create new NETCDF_DATA_MAP");
HashMap<String, NetCDFData> netCDFDataMap = new HashMap<>();
logger.debug("Add NetCDFData");
netCDFDataMap.put(netCDFData.getNetCDFId().getId(), netCDFData);
session.setAttribute(Constants.NETCDF_DATA_MAP, netCDFDataMap);
} else {
if (obj instanceof HashMap<?, ?>) {
@SuppressWarnings("unchecked")
HashMap<String, NetCDFData> netCDDataMap = (HashMap<String, NetCDFData>) obj;
if (netCDDataMap.containsKey(netCDFData.getNetCDFId().getId())) {
logger.debug("Error invalid NetCDFData in session");
throw new ServiceException("Invalid NetCDFData in session!");
} else {
logger.debug("Add NetCDFData");
netCDDataMap.put(netCDFData.getNetCDFId().getId(), netCDFData);
session.setAttribute(Constants.NETCDF_DATA_MAP, netCDDataMap);
}
} else {
logger.error("Attention no NetCDFDataMap in Session!");
throw new ServiceException("Sign Out, portlet is changed, a new session is required!");
}
}
return;
}
public static NetCDFData getNetCDFData(NetCDFId netCDFId, HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) throws ServiceException {
if (serviceCredentials == null) {
logger.error("ServiceCredentials is null!");
throw new ServiceException("Service Credentials is null!");
}
HttpSession session = httpRequest.getSession();
Object obj = session.getAttribute(Constants.NETCDF_DATA_MAP);
if (obj == null) {
logger.error("Attention no NetCDFDataMap in Session!");
throw new ServiceException("Sign Out, portlet is changed, a new session is required!");
} else {
if (obj instanceof HashMap<?, ?>) {
@SuppressWarnings("unchecked")
HashMap<String, NetCDFData> netCDFDataMap = (HashMap<String, NetCDFData>) obj;
if (netCDFDataMap.containsKey(netCDFId.getId())) {
logger.debug("Get NetCDFData in session");
return netCDFDataMap.get(netCDFId.getId());
} else {
logger.error("Attention no NetCDFData in Session!");
throw new ServiceException("Attention no NetCDFData in Session!");
}
} else {
logger.error("Attention no NetCDFDataMap in Session!");
throw new ServiceException("Sign Out, portlet is changed, a new session is required!");
}
}
}
public static void removeNetCDFData(NetCDFId netCDFId, HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) throws ServiceException {
if (serviceCredentials == null) {
logger.error("ServiceCredentials is null!");
throw new ServiceException("Service Credentials is null!");
}
HttpSession session = httpRequest.getSession();
Object obj = session.getAttribute(Constants.NETCDF_DATA_MAP);
if (obj == null) {
logger.error("Attention no NetCDFDataMap in Session!");
throw new ServiceException("Sign Out, portlet is changed, a new session is required!");
} else {
if (obj instanceof HashMap<?, ?>) {
@SuppressWarnings("unchecked")
HashMap<String, NetCDFData> netCDFDataMap = (HashMap<String, NetCDFData>) obj;
if (netCDFDataMap.containsKey(netCDFId.getId())) {
logger.debug("Remove NetCDFData in session");
netCDFDataMap.remove(netCDFId.getId());
} else {
logger.error("Attention no NetCDFData in Session!");
throw new ServiceException("Attention no NetCDFResource in Session!");
}
} else {
logger.error("Attention no NetCDFDataMap in Session!");
throw new ServiceException("Sign Out, portlet is changed, a new session is required!");
}
}
}
}

View File

@ -0,0 +1,403 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.NetCDFValueReader;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReader;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderBoolean;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderByte;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderChar;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderDouble;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderFloat;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderInt;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderLong;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderShort;
import org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior.ValueReaderString;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.exception.ServiceException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.AttributeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.DimensionData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFDetailData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFId;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.RangeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.Array;
import ucar.ma2.Range;
import ucar.nc2.Attribute;
import ucar.nc2.Dimension;
import ucar.nc2.NetcdfFile;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFResource {
//private static final String example1 = "http://data.d4science.org/Qnc4RXlNQmhlWS83NkFFb2dIU0hQMnhVTER1VEZjbGdHbWJQNStIS0N6Yz0";
private static final String example2 = "http://data.d4science.org/L0FuZGNERGNFL1Y4bDRQdDFHSmdFUkN5V3VvZlF4L2lHbWJQNStIS0N6Yz0";
//private static final String example3 = "http://data.d4science.org/WXZFNjRXeE9XWGQ4bDRQdDFHSmdFWVBPd0FEK0VzdlRHbWJQNStIS0N6Yz0";
private static Logger logger = LoggerFactory.getLogger(NetCDFId.class);
private URL publicLink;
private Path ncFile = null;
private NetcdfFile netcdfFile;
private NetCDFId netCDFId = null;
/*
* { System.loadLibrary("gdaljni"); }
*/
public NetCDFResource() throws ServiceException {
try {
this.publicLink = new URL(example2);
} catch (MalformedURLException e) {
logger.error(e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
retrievePublicLink();
this.netCDFId = new NetCDFId(ncFile.toAbsolutePath().toString());
}
public NetCDFResource(URL publicLink) throws ServiceException {
this.publicLink = publicLink;
retrievePublicLink();
this.netCDFId = new NetCDFId(ncFile.toAbsolutePath().toString());
}
public NetCDFResource(NetCDFId netCDFId) throws ServiceException {
this.netCDFId = netCDFId;
ncFile = Paths.get(netCDFId.getId());
}
public NetCDFId getNetCDFId() {
return netCDFId;
}
private void retrievePublicLink() throws ServiceException {
try {
ncFile = Files.createTempFile("NetCDFFile_", ".nc");
logger.debug("NetCDF Temp file: " + ncFile.toAbsolutePath().toString());
URLConnection uc = publicLink.openConnection();
try (InputStream is = uc.getInputStream()) {
BufferedInputStream bis = new BufferedInputStream(is);
OutputStream os = Files.newOutputStream(ncFile, StandardOpenOption.WRITE);
BufferedOutputStream bos = new BufferedOutputStream(os);
int data;
while ((data = bis.read()) != -1) {
bos.write(data);
}
}
} catch (IOException e) {
logger.error("Error retriving publicLink: " + publicLink);
logger.error(e.getLocalizedMessage(), e);
throw new ServiceException("Error retrieving publicLink: " + e.getLocalizedMessage(), e);
}
}
/*
* public void gdalExplore() { stringBuilder.append("GDAL: " +
* gdal.VersionInfo()); gdal.AllRegister(); stringBuilder.append("FILE: " +
* filename);
*
* Dataset dataset = gdal.Open(filename);//
* stringBuilder.append("Projection: " + dataset.GetProjection());
* stringBuilder.append("ProjectionRef: " + dataset.GetProjectionRef());
*
* Vector<?> vector = dataset.GetMetadata_List(); for (Object i : vector) {
* stringBuilder.append("MetaData: " + i); }
*
* int numBands = dataset.getRasterCount();
* stringBuilder.append("NumBands: " + numBands); }
*/
private void openNetcdfFile() throws ServiceException {
try {
netcdfFile = NetcdfFile.open(ncFile.toAbsolutePath().toString());
return;
} catch (Throwable e) {
logger.error("Error in NetcdfFile open: " + ncFile.toAbsolutePath().toString());
logger.error(e.getLocalizedMessage(), e);
throw new ServiceException("Error in NetcdfFile open", e);
}
}
public void close() throws ServiceException {
try {
deleteCNFile();
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
throw new ServiceException("Error in close: " + e.getLocalizedMessage(), e);
}
}
private void closeNetcdfFile() throws ServiceException {
try {
logger.debug("Close NetcdfFile");
if (netcdfFile != null) {
netcdfFile.close();
}
return;
} catch (Throwable e) {
logger.error("Error in netcdfFile close: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
private void deleteCNFile() throws ServiceException {
try {
if (ncFile != null) {
logger.debug("Delete ncFile: " + ncFile.toAbsolutePath().toString());
Files.delete(ncFile);
}
} catch (Throwable e) {
logger.error("Error deleting ncFile: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
public NetCDFData exploreNetCDF() throws ServiceException {
openNetcdfFile();
NetCDFData netCDFData = process();
closeNetcdfFile();
return netCDFData;
}
private NetCDFData process() {
NetCDFDetailData netCDFDetailData = processDetail();
ArrayList<DimensionData> dimensions = processDimensions();
ArrayList<VariableData> variables = processVariables();
NetCDFData netCDFData = new NetCDFData(netCDFId, netCDFDetailData, dimensions, variables);
return netCDFData;
}
private NetCDFDetailData processDetail() {
// String info = netcdfFile.getDetailInfo();
String typeId = netcdfFile.getFileTypeId();
String typeDescription = netcdfFile.getFileTypeDescription();
String typeVersion = netcdfFile.getFileTypeVersion();
// String title = netcdfFile.getTitle();
List<Attribute> globalAttrs = netcdfFile.getGlobalAttributes();
ArrayList<AttributeData> attributeDataList=readAttributes(globalAttrs);
NetCDFDetailData netCDFDetailData = new NetCDFDetailData(typeId, typeDescription, typeVersion, attributeDataList);
return netCDFDetailData;
}
private ArrayList<AttributeData> readAttributes(List<Attribute> attributes) {
ArrayList<AttributeData> attributeDataList = new ArrayList<>();
for (int i = 0; i < attributes.size(); i++) {
Attribute attr = attributes.get(i);
String values = new String();
if (attr.isArray()) {
Array vals = attr.getValues();
values = vals.toString();
} else {
if (attr.isString()) {
values = attr.getStringValue();
} else {
Number num = attr.getNumericValue();
switch (attr.getDataType()) {
case BYTE:
values = String.valueOf(num.byteValue());
break;
case SHORT:
values = String.valueOf(num.shortValue());
break;
case INT:
values = String.valueOf(num.intValue());
break;
case FLOAT:
values = String.valueOf(num.floatValue());
break;
case DOUBLE:
values = String.valueOf(num.doubleValue());
break;
case LONG:
values = String.valueOf(num.longValue());
break;
default:
break;
}
}
}
AttributeData attributeData=new AttributeData(i, attr.getFullName(), attr.getDataType().name(), values);
attributeDataList.add(attributeData);
}
return attributeDataList;
}
private ArrayList<VariableData> processVariables() {
ArrayList<VariableData> varsData = new ArrayList<>();
List<Variable> variables = netcdfFile.getVariables();
for (int i = 0; i < variables.size(); i++) {
Variable variable = variables.get(i);
ArrayList<DimensionData> dimsData = new ArrayList<>();
List<Dimension> dims = variable.getDimensions();
for (int j = 0; j < dims.size(); j++) {
Dimension dim = dims.get(j);
DimensionData dimData = new DimensionData(j, dim.getFullName(), dim.getLength(), dim.isUnlimited(),
dim.isVariableLength(), dim.isShared());
dimsData.add(dimData);
}
List<Attribute> attributes = variable.getAttributes();
ArrayList<AttributeData> attrsData = readAttributes(attributes);
List<Range> ranges=variable.getRanges();
ArrayList<RangeData> rangesData=new ArrayList<>();
for(int k=0;k<ranges.size();k++){
Range range=ranges.get(k);
RangeData rangeData=new RangeData(k,range.length(),range.first(),range.stride(),range.getName() );
rangesData.add(rangeData);
}
VariableData variableData = new VariableData(i, variable.getFullName(), variable.getUnitsString(),
variable.getDataType().name(), variable.getDimensionsString(), variable.getRank(),
variable.isCoordinateVariable(), variable.isScalar(), variable.isImmutable(),
variable.isUnlimited(), variable.isUnsigned(), variable.isVariableLength(),
variable.isMemberOfStructure(), dimsData, attrsData,rangesData);
varsData.add(variableData);
}
return varsData;
}
private ArrayList<DimensionData> processDimensions() {
ArrayList<DimensionData> dimsData = new ArrayList<>();
List<Dimension> dims = netcdfFile.getDimensions();
for (int i = 0; i < dims.size(); i++) {
Dimension dim = dims.get(i);
DimensionData dimData = new DimensionData(i, dim.getFullName(), dim.getLength(), dim.isUnlimited(),
dim.isVariableLength(), dim.isShared());
dimsData.add(dimData);
}
return dimsData;
}
public NetCDFValues readDataVariable(VariableData variableData, boolean sample, int limit) throws ServiceException {
openNetcdfFile();
NetCDFValues netCDFValues = readDataInVariable(variableData, sample, limit);
closeNetcdfFile();
return netCDFValues;
}
private NetCDFValues readDataInVariable(VariableData variableData, boolean sample, int limit)
throws ServiceException {
List<Variable> vars = netcdfFile.getVariables();
Variable foundVar = null;
for (Variable var : vars) {
if (var.getFullName().compareTo(variableData.getFullName()) == 0) {
foundVar = var;
break;
}
}
if (foundVar == null) {
throw new ServiceException("Variable " + variableData.getFullName() + "not found!");
}
return elaborateVariable(foundVar, sample, limit);
}
private NetCDFValues elaborateVariable(Variable variable, boolean sample, int limit) {
ValueReader valueReader = new ValueReader();
switch (variable.getDataType()) {
case BOOLEAN:
valueReader = new ValueReaderBoolean();
break;
case BYTE:
valueReader = new ValueReaderByte();
break;
case CHAR:
valueReader = new ValueReaderChar();
break;
case DOUBLE:
valueReader = new ValueReaderDouble();
break;
case ENUM1:
break;
case ENUM2:
break;
case ENUM4:
break;
case FLOAT:
valueReader = new ValueReaderFloat();
break;
case INT:
valueReader = new ValueReaderInt();
break;
case LONG:
valueReader = new ValueReaderLong();
break;
case OBJECT:
break;
case OPAQUE:
break;
case SEQUENCE:
break;
case SHORT:
valueReader = new ValueReaderShort();
break;
case STRING:
valueReader = new ValueReaderString();
break;
case STRUCTURE:
break;
default:
break;
}
NetCDFValues netCDFValues = null;
NetCDFValueReader netCDFValueReader = new NetCDFValueReader();
if (sample) {
netCDFValues = netCDFValueReader.sample(variable, limit, valueReader);
} else {
netCDFValues = netCDFValueReader.apply(variable, valueReader);
}
return netCDFValues;
}
}

View File

@ -0,0 +1,25 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFValueReader {
public NetCDFValues apply(Variable variable, ValueReader valueReader) {
return valueReader.apply(variable);
}
public NetCDFValues sample(Variable variable,int limit, ValueReader valueReader) {
return valueReader.sample(variable, limit);
}
}

View File

@ -0,0 +1,23 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReader {
public NetCDFValues apply(Variable variable) {
return null;
}
public NetCDFValues sample(Variable variable, int limits) {
return null;
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataBoolean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayBoolean;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderBoolean extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderBoolean.class);
public NetCDFValues apply(Variable variable) {
boolean[] data = elaborate(variable, false, 0);
ArrayDataBoolean arrayData = new ArrayDataBoolean(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
boolean[] data = elaborate(variable, true, limit);
ArrayDataBoolean arrayData = new ArrayDataBoolean(data);
return new NetCDFValues(arrayData);
}
private boolean[] elaborate(Variable variable, boolean sample, int limit) {
try {
ArrayBoolean dataArray = (ArrayBoolean) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if (sample) {
totalLen = totalLen < limit ? totalLen : limit;
}
boolean[] data = new boolean[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = dataArray.getBoolean(i);
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataByte;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayByte;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderByte extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderByte.class);
public NetCDFValues apply(Variable variable) {
byte[] data = elaborate(variable, false, 0);
ArrayDataByte arrayData = new ArrayDataByte(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
byte[] data = elaborate(variable, true, limit);
ArrayDataByte arrayData = new ArrayDataByte(data);
return new NetCDFValues(arrayData);
}
private byte[] elaborate(Variable variable, boolean sample, int limit) {
try {
ArrayByte dataArray = (ArrayByte) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if (sample) {
totalLen = totalLen < limit ? totalLen : limit;
}
byte[] data = new byte[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = dataArray.getByte(i);
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataChar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayChar;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderChar extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderChar.class);
public NetCDFValues apply(Variable variable) {
char[] data = elaborate(variable, false, 0);
ArrayDataChar arrayData = new ArrayDataChar(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
char[] data = elaborate(variable, true, limit);
ArrayDataChar arrayData = new ArrayDataChar(data);
return new NetCDFValues(arrayData);
}
private char[] elaborate(Variable variable, boolean sample, int limit) {
try {
ArrayChar dataArray = (ArrayChar) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if (sample) {
totalLen = totalLen < limit ? totalLen : limit;
}
char[] data = new char[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = dataArray.getChar(i);
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,71 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataDouble;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayDouble;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderDouble extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderDouble.class);
public NetCDFValues apply(Variable variable) {
double[] data = elaborate(variable, false, 0);
ArrayDataDouble arrayData = new ArrayDataDouble(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
double[] data = elaborate(variable, true, limit);
ArrayDataDouble arrayData = new ArrayDataDouble(data);
return new NetCDFValues(arrayData);
}
private double[] elaborate(Variable variable,boolean sample, int limit) {
try {
ArrayDouble dataArray = (ArrayDouble) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if(sample){
totalLen = totalLen < limit?totalLen:limit;
}
double[] data = new double[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = dataArray.getFloat(i);
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataFloat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayFloat;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderFloat extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderFloat.class);
public NetCDFValues apply(Variable variable) {
float[] data = elaborate(variable, false, 0);
ArrayDataFloat arrayData = new ArrayDataFloat(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
float[] data = elaborate(variable, true, limit);
ArrayDataFloat arrayData = new ArrayDataFloat(data);
return new NetCDFValues(arrayData);
}
private float[] elaborate(Variable variable, boolean sample, int limit) {
try {
ArrayFloat dataArray = (ArrayFloat) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if (sample) {
totalLen = totalLen < limit ? totalLen : limit;
}
float[] data = new float[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = dataArray.getFloat(i);
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataInt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayInt;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderInt extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderInt.class);
public NetCDFValues apply(Variable variable) {
int[] data = elaborate(variable, false, 0);
ArrayDataInt arrayData = new ArrayDataInt(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
int[] data = elaborate(variable, true, limit);
ArrayDataInt arrayData = new ArrayDataInt(data);
return new NetCDFValues(arrayData);
}
private int[] elaborate(Variable variable, boolean sample, int limit) {
try {
ArrayInt dataArray = (ArrayInt) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if (sample) {
totalLen = totalLen < limit ? totalLen : limit;
}
int[] data = new int[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = dataArray.getInt(i);
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataLong;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayLong;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderLong extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderLong.class);
public NetCDFValues apply(Variable variable) {
long[] data = elaborate(variable, false, 0);
ArrayDataLong arrayData = new ArrayDataLong(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
long[] data = elaborate(variable, true, limit);
ArrayDataLong arrayData = new ArrayDataLong(data);
return new NetCDFValues(arrayData);
}
private long[] elaborate(Variable variable, boolean sample, int limit) {
try {
ArrayLong dataArray = (ArrayLong) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if (sample) {
totalLen = totalLen < limit ? totalLen : limit;
}
long[] data = new long[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = dataArray.getLong(i);
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataShort;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayShort;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderShort extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderShort.class);
public NetCDFValues apply(Variable variable) {
short[] data = elaborate(variable, false, 0);
ArrayDataShort arrayData = new ArrayDataShort(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
short[] data = elaborate(variable, true, limit);
ArrayDataShort arrayData = new ArrayDataShort(data);
return new NetCDFValues(arrayData);
}
private short[] elaborate(Variable variable, boolean sample, int limit) {
try {
ArrayShort dataArray = (ArrayShort) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if (sample) {
totalLen = totalLen < limit ? totalLen : limit;
}
short[] data = new short[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = dataArray.getShort(i);
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,70 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.netcdf.behavior;
import java.io.IOException;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFValues;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayDataString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.ma2.ArrayString;
import ucar.nc2.Variable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ValueReaderString extends ValueReader {
private static Logger logger = LoggerFactory.getLogger(ValueReaderString.class);
public NetCDFValues apply(Variable variable) {
String[] data = elaborate(variable, false, 0);
ArrayDataString arrayData = new ArrayDataString(data);
return new NetCDFValues(arrayData);
}
public NetCDFValues sample(Variable variable, int limit) {
String[] data = elaborate(variable, true, limit);
ArrayDataString arrayData = new ArrayDataString(data);
return new NetCDFValues(arrayData);
}
private String[] elaborate(Variable variable, boolean sample, int limit) {
try {
ArrayString dataArray = (ArrayString) variable.read();
int[] shape = dataArray.getShape();
int totalLen = 1;
for (int len : shape) {
totalLen *= len;
}
if (sample) {
totalLen = totalLen < limit ? totalLen : limit;
}
String[] data = new String[totalLen];
for (int i = 0; i < totalLen; i++) {
data[i] = (dataArray.getObject(i)).toString();
}
return data;
} catch (IOException e) {
logger.error("Error reading data: " + e.getLocalizedMessage(), e);
throw new RuntimeException("Error reading data: " + e.getLocalizedMessage(), e);
}
}
}

View File

@ -0,0 +1,141 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.server.util;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ServiceCredentials implements Serializable {
private static final long serialVersionUID = 3560918948310315680L;
private String userName;
private String fullName;
private String name;
private String lastName;
private String email;
private String scope;
private String groupId;
private String groupName;
private String userAvatarURL;
private String token;
public ServiceCredentials() {
super();
}
public ServiceCredentials(String userName, String scope, String token) {
super();
this.userName = userName;
this.scope = scope;
this.token = token;
}
public ServiceCredentials(String userName, String fullName, String name,
String lastName, String email, String scope, String groupId,
String groupName, String userAvatarURL, String token) {
super();
this.userName = userName;
this.fullName = fullName;
this.name = name;
this.lastName = lastName;
this.email = email;
this.scope = scope;
this.groupId = groupId;
this.groupName = groupName;
this.userAvatarURL = userAvatarURL;
this.token = token;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getUserAvatarURL() {
return userAvatarURL;
}
public void setUserAvatarURL(String userAvatarURL) {
this.userAvatarURL = userAvatarURL;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
@Override
public String toString() {
return "ServiceCredentials [userName=" + userName + ", fullName="
+ fullName + ", name=" + name + ", lastName=" + lastName
+ ", email=" + email + ", scope=" + scope + ", groupId="
+ groupId + ", groupName=" + groupName + ", userAvatarURL="
+ userAvatarURL + ", token=" + token + "]";
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class Constants {
public static final boolean DEBUG_MODE = true;
public static final boolean TEST_ENABLE = false;
public static final String DEFAULT_USER = "giancarlo.panichi";
public static final String DEFAULT_ROLE = "OrganizationMember";
public static final String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
public static final String DEFAULT_TOKEN = "ae1208f0-210d-47c9-9b24-d3f2dfcce05f-98187548";
public static final String NETCDF_DATA_MAP="NETCDF_DATA_MAP";
public static final int SAMPLE_LENGHT = 200;
}

View File

@ -0,0 +1,42 @@
/**
*
*/
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.exception;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ServiceException extends Exception {
private static final long serialVersionUID = -2255657546267656458L;
/**
*
*/
public ServiceException() {
super();
}
/**
* @param message
* message
*/
public ServiceException(String message) {
super(message);
}
/**
*
* @param message
* message
* @param throwable
* error
*/
public ServiceException(String message, Throwable throwable) {
super(message, throwable);
}
}

View File

@ -0,0 +1,40 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.exception;
/**
* Session Expired Service Exception
*
* @author Giancarlo Panichi
*
*/
public class SessionExpiredServiceException extends ServiceException {
private static final long serialVersionUID = -4831171355042165166L;
/**
*
*/
public SessionExpiredServiceException() {
super();
}
/**
*
* @param message
* message
*/
public SessionExpiredServiceException(String message) {
super(message);
}
/**
*
* @param message
* message
* @param throwable
* errror
*/
public SessionExpiredServiceException(String message, Throwable throwable) {
super(message, throwable);
}
}

View File

@ -0,0 +1,100 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf;
import java.io.Serializable;
import com.google.gwt.view.client.ProvidesKey;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class AttributeData implements Serializable, Comparable<AttributeData> {
private static final long serialVersionUID = -273113960995381444L;
/**
* The key provider that provides the unique ID of a variable.
*/
public static final ProvidesKey<AttributeData> KEY_PROVIDER = new ProvidesKey<AttributeData>() {
@Override
public Object getKey(AttributeData attributeData) {
return attributeData == null ? null : attributeData.getId();
}
};
private int id;
private String fullName;
private String dataType;
private String values;
public AttributeData() {
super();
}
public AttributeData(int id, String fullName, String dataType, String values) {
super();
this.id = id;
this.fullName = fullName;
this.dataType = dataType;
this.values = values;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getValues() {
return values;
}
public void setValues(String values) {
this.values = values;
}
@Override
public int compareTo(AttributeData attributeData) {
return (id < attributeData.id) ? -1 : ((id == attributeData.id) ? 0 : 1);
}
@Override
public boolean equals(Object o) {
if (o instanceof AttributeData) {
return id == ((AttributeData) o).id;
}
return false;
}
@Override
public int hashCode() {
return id;
}
@Override
public String toString() {
return "AttributeData [id=" + id + ", fullName=" + fullName + ", dataType=" + dataType + ", values=" + values
+ "]";
}
}

View File

@ -0,0 +1,93 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class DimensionData implements Serializable {
private static final long serialVersionUID = 4540272192257245556L;
private int id;
private String fullName;
private int lenght;
private boolean unlimited;
private boolean variable;
private boolean shared;
public DimensionData() {
super();
}
public DimensionData(int id,String fullName, int lenght, boolean unlimited, boolean variable, boolean shared) {
super();
this.id=id;
this.fullName = fullName;
this.lenght = lenght;
this.unlimited = unlimited;
this.variable = variable;
this.shared = shared;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public int getLenght() {
return lenght;
}
public void setLenght(int lenght) {
this.lenght = lenght;
}
public boolean isUnlimited() {
return unlimited;
}
public void setUnlimited(boolean unlimited) {
this.unlimited = unlimited;
}
public boolean isVariable() {
return variable;
}
public void setVariable(boolean variable) {
this.variable = variable;
}
public boolean isShared() {
return shared;
}
public void setShared(boolean shared) {
this.shared = shared;
}
@Override
public String toString() {
return "DimensionData [id=" + id + ", fullName=" + fullName + ", lenght=" + lenght + ", unlimited=" + unlimited
+ ", variable=" + variable + ", shared=" + shared + "]";
}
}

View File

@ -0,0 +1,72 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFData implements Serializable {
private static final long serialVersionUID = -5329486981700757821L;
private NetCDFId netCDFId;
private NetCDFDetailData detail;
private ArrayList<DimensionData> dimensions;
private ArrayList<VariableData> variables;
public NetCDFData() {
super();
}
public NetCDFData(NetCDFId netCDFId, NetCDFDetailData detail, ArrayList<DimensionData> dimensions,
ArrayList<VariableData> variables) {
super();
this.netCDFId = netCDFId;
this.detail = detail;
this.dimensions = dimensions;
this.variables = variables;
}
public NetCDFId getNetCDFId() {
return netCDFId;
}
public void setNetCDFId(NetCDFId netCDFId) {
this.netCDFId = netCDFId;
}
public NetCDFDetailData getDetail() {
return detail;
}
public void setDetail(NetCDFDetailData detail) {
this.detail = detail;
}
public ArrayList<VariableData> getVariables() {
return variables;
}
public void setVariables(ArrayList<VariableData> variables) {
this.variables = variables;
}
public ArrayList<DimensionData> getDimensions() {
return dimensions;
}
public void setDimensions(ArrayList<DimensionData> dimensions) {
this.dimensions = dimensions;
}
@Override
public String toString() {
return "NetCDFData [netCDFId=" + netCDFId + ", detail=" + detail + ", dimensions=" + dimensions + ", variables="
+ variables + "]";
}
}

View File

@ -0,0 +1,74 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFDetailData implements Serializable {
private static final long serialVersionUID = -4421993747362744743L;
// private String info;
// private String title;
private String typeId;
private String typeDescription;
private String typeVersion;
private ArrayList<AttributeData> globalAttributeDataList;
public NetCDFDetailData() {
super();
}
public NetCDFDetailData(String typeId, String typeDescription, String typeVersion,
ArrayList<AttributeData> globalAttributeDataList) {
super();
this.typeId = typeId;
this.typeDescription = typeDescription;
this.typeVersion = typeVersion;
this.globalAttributeDataList = globalAttributeDataList;
}
public String getTypeId() {
return typeId;
}
public void setTypeId(String typeId) {
this.typeId = typeId;
}
public String getTypeDescription() {
return typeDescription;
}
public void setTypeDescription(String typeDescription) {
this.typeDescription = typeDescription;
}
public String getTypeVersion() {
return typeVersion;
}
public void setTypeVersion(String typeVersion) {
this.typeVersion = typeVersion;
}
public ArrayList<AttributeData> getGlobalAttributeDataList() {
return globalAttributeDataList;
}
public void setGlobalAttributeDataList(ArrayList<AttributeData> globalAttributeDataList) {
this.globalAttributeDataList = globalAttributeDataList;
}
@Override
public String toString() {
return "NetCDFDetailData [typeId=" + typeId + ", typeDescription=" + typeDescription + ", typeVersion="
+ typeVersion + ", globalAttributeDataList=" + globalAttributeDataList + "]";
}
}

View File

@ -0,0 +1,38 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFId implements Serializable {
private static final long serialVersionUID = -702861298258611976L;
private String id;
public NetCDFId() {
super();
}
public NetCDFId(String id) {
super();
this.id = id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public String toString() {
return "NetCDFId [id=" + id + "]";
}
}

View File

@ -0,0 +1,41 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf;
import java.io.Serializable;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata.ArrayData;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NetCDFValues implements Serializable {
private static final long serialVersionUID = -60684556484226449L;
private ArrayData arrayData;
public NetCDFValues() {
super();
}
public NetCDFValues(ArrayData arrayData) {
super();
this.arrayData = arrayData;
}
public ArrayData getArrayData() {
return arrayData;
}
public void setArrayData(ArrayData arrayData) {
this.arrayData = arrayData;
}
@Override
public String toString() {
return "NetCDFValues [arrayData=" + arrayData + "]";
}
}

View File

@ -0,0 +1,109 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf;
import java.io.Serializable;
import com.google.gwt.view.client.ProvidesKey;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class RangeData implements Serializable, Comparable<RangeData> {
private static final long serialVersionUID = -6854880075565748144L;
/**
* The key provider that provides the unique ID of a variable.
*/
public static final ProvidesKey<RangeData> KEY_PROVIDER = new ProvidesKey<RangeData>() {
@Override
public Object getKey(RangeData rangeData) {
return rangeData == null ? null : rangeData.getId();
}
};
private int id;
private int n; // number of elements
private int first; // first value in range
private int stride; // stride, must be >= 1
private String name; // optional name
public RangeData() {
super();
}
public RangeData(int id, int n, int first, int stride, String name) {
super();
this.id = id;
this.n = n;
this.first = first;
this.stride = stride;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getN() {
return n;
}
public void setN(int n) {
this.n = n;
}
public int getFirst() {
return first;
}
public void setFirst(int first) {
this.first = first;
}
public int getStride() {
return stride;
}
public void setStride(int stride) {
this.stride = stride;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public int compareTo(RangeData rangeData) {
return (id < rangeData.id) ? -1 : ((id == rangeData.id) ? 0 : 1);
}
@Override
public boolean equals(Object o) {
if (o instanceof RangeData) {
return id == ((RangeData) o).id;
}
return false;
}
@Override
public int hashCode() {
return id;
}
@Override
public String toString() {
return "RangeData [id=" + id + ", n=" + n + ", first=" + first + ", stride=" + stride + ", name=" + name + "]";
}
}

View File

@ -0,0 +1,228 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf;
import java.io.Serializable;
import java.util.ArrayList;
import com.google.gwt.view.client.ProvidesKey;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class VariableData implements Serializable, Comparable<VariableData> {
private static final long serialVersionUID = -5329486981700757821L;
/**
* The key provider that provides the unique ID of a variable.
*/
public static final ProvidesKey<VariableData> KEY_PROVIDER = new ProvidesKey<VariableData>() {
@Override
public Object getKey(VariableData variableData) {
return variableData == null ? null : variableData.getId();
}
};
private int id;
private String fullName;
private String units;
private String dataType;
private String dimensionString;
private int rank;
private boolean coordinateVariable;
private boolean scalar;
private boolean immutable;
private boolean unlimited;
private boolean unsigned;
private boolean variableLength;
private boolean memberOfStructure;
private ArrayList<DimensionData> dimensions;
private ArrayList<AttributeData> attributes;
private ArrayList<RangeData> ranges;
public VariableData() {
super();
}
public VariableData(int id, String fullName, String units, String dataType, String dimensionString, int rank,
boolean coordinateVariable, boolean scalar, boolean immutable, boolean unlimited, boolean unsigned,
boolean variableLength, boolean memberOfStructure, ArrayList<DimensionData> dimensions,
ArrayList<AttributeData> attributes, ArrayList<RangeData> ranges) {
super();
this.id = id;
this.fullName = fullName;
this.units = units;
this.dataType = dataType;
this.dimensionString = dimensionString;
this.rank = rank;
this.coordinateVariable = coordinateVariable;
this.scalar = scalar;
this.immutable = immutable;
this.unlimited = unlimited;
this.unsigned = unsigned;
this.variableLength = variableLength;
this.memberOfStructure = memberOfStructure;
this.dimensions = dimensions;
this.attributes = attributes;
this.ranges = ranges;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getUnits() {
return units;
}
public void setUnits(String units) {
this.units = units;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getDimensionString() {
return dimensionString;
}
public void setDimensionString(String dimensionString) {
this.dimensionString = dimensionString;
}
public int getRank() {
return rank;
}
public void setRank(int rank) {
this.rank = rank;
}
public boolean isCoordinateVariable() {
return coordinateVariable;
}
public void setCoordinateVariable(boolean coordinateVariable) {
this.coordinateVariable = coordinateVariable;
}
public boolean isScalar() {
return scalar;
}
public void setScalar(boolean scalar) {
this.scalar = scalar;
}
public boolean isImmutable() {
return immutable;
}
public void setImmutable(boolean immutable) {
this.immutable = immutable;
}
public boolean isUnlimited() {
return unlimited;
}
public void setUnlimited(boolean unlimited) {
this.unlimited = unlimited;
}
public boolean isUnsigned() {
return unsigned;
}
public void setUnsigned(boolean unsigned) {
this.unsigned = unsigned;
}
public boolean isVariableLength() {
return variableLength;
}
public void setVariableLength(boolean variableLength) {
this.variableLength = variableLength;
}
public boolean isMemberOfStructure() {
return memberOfStructure;
}
public void setMemberOfStructure(boolean memberOfStructure) {
this.memberOfStructure = memberOfStructure;
}
public ArrayList<DimensionData> getDimensions() {
return dimensions;
}
public void setDimensions(ArrayList<DimensionData> dimensions) {
this.dimensions = dimensions;
}
public ArrayList<AttributeData> getAttributes() {
return attributes;
}
public void setAttributes(ArrayList<AttributeData> attributes) {
this.attributes = attributes;
}
public ArrayList<RangeData> getRanges() {
return ranges;
}
public void setRanges(ArrayList<RangeData> ranges) {
this.ranges = ranges;
}
@Override
public int compareTo(VariableData variableData) {
return (id < variableData.id) ? -1 : ((id == variableData.id) ? 0 : 1);
}
@Override
public boolean equals(Object o) {
if (o instanceof VariableData) {
return id == ((VariableData) o).id;
}
return false;
}
@Override
public int hashCode() {
return id;
}
@Override
public String toString() {
return "VariableData [id=" + id + ", fullName=" + fullName + ", units=" + units + ", dataType=" + dataType
+ ", dimensionString=" + dimensionString + ", rank=" + rank + ", coordinateVariable="
+ coordinateVariable + ", scalar=" + scalar + ", immutable=" + immutable + ", unlimited=" + unlimited
+ ", unsigned=" + unsigned + ", variableLength=" + variableLength + ", memberOfStructure="
+ memberOfStructure + ", dimensions=" + dimensions + ", attributes=" + attributes + ", ranges=" + ranges
+ "]";
}
}

View File

@ -0,0 +1,32 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayData implements Serializable {
private static final long serialVersionUID = -5819190300039031091L;
public ArrayData(){
super();
}
public String asString(){
return "";
}
@Override
public String toString() {
return "ArrayData []";
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataBoolean extends ArrayData {
private static final long serialVersionUID = 376775487416054751L;
private boolean[] data;
public ArrayDataBoolean() {
super();
}
public ArrayDataBoolean(boolean[] data) {
super();
this.data = data;
}
public boolean[] getData() {
return data;
}
public void setData(boolean[] data) {
this.data = data;
}
public String asString() {
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataBoolean [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataByte extends ArrayData {
private static final long serialVersionUID = -6974556500776290487L;
private byte[] data;
public ArrayDataByte() {
super();
}
public ArrayDataByte(byte[] data) {
super();
this.data = data;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String asString() {
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataByte [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataChar extends ArrayData {
private static final long serialVersionUID = 2958263201966665385L;
private char[] data;
public ArrayDataChar() {
super();
}
public ArrayDataChar(char[] data) {
super();
this.data = data;
}
public char[] getData() {
return data;
}
public void setData(char[] data) {
this.data = data;
}
public String asString() {
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataChar [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,44 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataDouble extends ArrayData {
private static final long serialVersionUID = 8662144557829864644L;
private double[] data;
public ArrayDataDouble(){
super();
}
public ArrayDataDouble(double[] data) {
super();
this.data = data;
}
public double[] getData() {
return data;
}
public void setData(double[] data) {
this.data = data;
}
public String asString(){
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataDouble [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataFloat extends ArrayData {
private static final long serialVersionUID = -5059700701483524112L;
private float[] data;
public ArrayDataFloat() {
super();
}
public ArrayDataFloat(float[] data) {
super();
this.data = data;
}
public float[] getData() {
return data;
}
public void setData(float[] data) {
this.data = data;
}
public String asString() {
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataFloat [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataInt extends ArrayData {
private static final long serialVersionUID = 5381922244689509206L;
private int[] data;
public ArrayDataInt() {
super();
}
public ArrayDataInt(int[] data) {
super();
this.data = data;
}
public int[] getData() {
return data;
}
public void setData(int[] data) {
this.data = data;
}
public String asString() {
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataInt [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataLong extends ArrayData {
private static final long serialVersionUID = 5381922244689509206L;
private long[] data;
public ArrayDataLong() {
super();
}
public ArrayDataLong(long[] data) {
super();
this.data = data;
}
public long[] getData() {
return data;
}
public void setData(long[] data) {
this.data = data;
}
public String asString() {
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataLong [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataShort extends ArrayData {
private static final long serialVersionUID = 6129653301969954455L;
private short[] data;
public ArrayDataShort() {
super();
}
public ArrayDataShort(short[] data) {
super();
this.data = data;
}
public short[] getData() {
return data;
}
public void setData(short[] data) {
this.data = data;
}
public String asString() {
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataShort [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,43 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.arraydata;
import java.util.Arrays;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ArrayDataString extends ArrayData {
private static final long serialVersionUID = -800750497029042816L;
private String[] data;
public ArrayDataString() {
super();
}
public ArrayDataString(String[] data) {
super();
this.data = data;
}
public String[] getData() {
return data;
}
public void setData(String[] data) {
this.data = data;
}
public String asString() {
return Arrays.toString(data);
}
@Override
public String toString() {
return "ArrayDataShort [data=" + Arrays.toString(data) + "]";
}
}

View File

@ -0,0 +1,95 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.shared.session;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class UserInfo implements Serializable {
private static final long serialVersionUID = -2826549639677017234L;
private String username;
private String groupId;
private String groupName;
private String scope;
private String userEmailAddress;
private String userFullName;
public UserInfo() {
super();
}
public UserInfo(String username, String groupId, String groupName,
String scope, String userEmailAddress, String userFullName) {
super();
this.username = username;
this.groupId = groupId;
this.groupName = groupName;
this.scope = scope;
this.userEmailAddress = userEmailAddress;
this.userFullName = userFullName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getUserEmailAddress() {
return userEmailAddress;
}
public void setUserEmailAddress(String userEmailAddress) {
this.userEmailAddress = userEmailAddress;
}
public String getUserFullName() {
return userFullName;
}
public void setUserFullName(String userFullName) {
this.userFullName = userFullName;
}
@Override
public String toString() {
return "UserInfo [username=" + username + ", groupId=" + groupId
+ ", groupName=" + groupName + ", scope=" + scope
+ ", userEmailAddress=" + userEmailAddress + ", userFullName="
+ userFullName + "]";
}
}

View File

@ -0,0 +1 @@
< ャ@Qaj、F÷gク<67>

View File

@ -0,0 +1 @@
< ャ@Qaj、F÷gク<67>

View File

@ -0,0 +1 @@
6 4Z<34>/U<><55> C<><43>ߘ

View File

@ -0,0 +1 @@
6 4Z<34>/U<><55> C<><43>ߘ

View File

@ -0,0 +1 @@
< ャ@Qaj、F÷gク<67>

View File

@ -0,0 +1 @@
6 4Z<34>/U<><55> C<><43>ߘ

View File

@ -0,0 +1,6 @@
You should put the infrastructure decrypt keys here.
the keys must be in named "<scope name>.gcubekey", e.g. "gcube.gcubekey" or "devsec.gcubekey"
The content of this folder is automatically loaded in the classpath when tomcat starts up.

View File

@ -0,0 +1,20 @@
# A default log4j configuration for log4j users.
#
# To use this configuration, deploy it into your application's WEB-INF/classes
# directory. You are also encouraged to edit it as you like.
log4j.rootLogger=DEBUG, stdout, rollingFile
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
log4j.appender.rollingFile.File=test.log
log4j.appender.rollingFile.MaxFileSize=20MB
log4j.appender.rollingFile.MaxBackupIndex=2
log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout
log4j.appender.rollingFile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

View File

@ -0,0 +1,66 @@
@CHARSET "UTF-8";
/* Dialog tool button */
.dialog-tool-button-text {
margin-left: -20px;
margin-top: 2px;
}
.dialog-tool-button-text:hover {
margin-left: -20px;
margin-top: 0px;
}
.dialog-tool-button-icon {
height: 20px;
}
.dialog-tool-button-icon:hover {
height: 20px;
border: 1px solid #222;
}
/**/
.area-selection-panel {
border: 1px solid #ccc;
background-color: white;
margin-top: 4px;
margin-bottom: 4px;
}
.area-selection-content {
margin: 4px;
}
/* Progress */
.progress-bar-container {
width: 100%;
height: 25px;
position: relative;
background-color: #f1f1f1;
}
.progress-bar {
color: #fff;
background-color: #a5a5a5;
height: 100%;
position: absolute;
line-height: inherit;
}
.progress-bar-text {
text-align: center;
color: #2d2d2d;
position: absolute;
width: 100%;
margin-top: 5px;
}
/* Form */
.wkt-geometry-text-area {
width: 400px !important;
}
.combo-geometry-type {
width: 406px !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

View File

@ -0,0 +1,34 @@
dialogTitle=NetCDF Preview
variablesTab=Variables
detailTab=Detail
sampleTab=Sample
infoTab=Info
columnFullname=Name
columnUnits=Units
columnDataType=DataType
columnDimensionString=Dimensions
columnRank=Rank
columnCoordinateVariable=Coord.
columnScalar=Scalar
columnImmutable=Immutable
columnUnlimited=Unlimited
columnUnsigned=Unsigned
columnVariableLenght=VLenght
columnMemberOfStructure=Member
columnValue=Value
columnName=Name
columnN=N
columnFirst=First
columnStride=Stride
dataGridVariablesDescription=List of variables in nectdf file
dataGridVariablesEmpty=No Variable;
dataGridVariablesName=NetCDF Variables
dataGridGlobalAttributeDescription=List of global attributes in nectdf file
dataGridGlobalAttributeEmpty=No Global Attribute
dataGridGlobalAttributeName=NetCDF Global Attributes
dataGridAttributeOfVariableDescription=List of attributes of variable
dataGridAttributeOfVariableEmpty=No Attribute
dataGridAttributeOfVariableName=Attributes
dataGridRangeOfVariableDescription=List of range of variable
dataGridRangeOfVariableEmpty=No Range
dataGridRangeOfVariableName=Ranges

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='netcdfbasicwidgets'>
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<inherits name="com.google.gwt.resources.Resources" />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<!-- Debug CSS style -->
<!-- <set-configuration-property name="CssResource.style"
value="pretty" /> -->
<!--
<entry-point class='org.gcube.portlets.widgets.netcdfbasicwidgets.client.NetCDFBasicWidgets'
/> -->
<!-- <set-property name="gwt.logging.enabled" value="TRUE" /> <set-property
name="gwt.logging.logLevel" value="SEVERE" /> <set-property name="gwt.logging.consoleHandler"
value="ENABLED" /> <set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED"
/> -->
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
<!-- <set-property name="log_ConsoleLogger" value="DISABLED" /> <set-property
name="log_DivLogger" value="DISABLED" /> <set-property name="log_GWTLogger"
value="DISABLED" /> <set-property name="log_SystemLogger" value="DISABLED"
/> -->
<source path='client' />
<source path='shared' />
</module>

View File

@ -0,0 +1 @@
.ol-control,.ol-scale-line{position:absolute;padding:2px}.ol-box{box-sizing:border-box;border-radius:2px;border:2px solid #00f}.ol-mouse-position{top:8px;right:8px;position:absolute}.ol-scale-line{background:rgba(0,60,136,.3);border-radius:4px;bottom:8px;left:8px}.ol-scale-line-inner{border:1px solid #eee;border-top:none;color:#eee;font-size:10px;text-align:center;margin:1px;will-change:contents,width}.ol-overlay-container{will-change:left,right,top,bottom}.ol-unsupported{display:none}.ol-viewport .ol-unselectable{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-control{background-color:rgba(255,255,255,.4);border-radius:4px}.ol-control:hover{background-color:rgba(255,255,255,.6)}.ol-zoom{top:.5em;left:.5em}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{right:.5em;top:.5em}@media print{.ol-control{display:none}}.ol-control button{display:block;margin:1px;padding:0;color:#fff;font-size:1.14em;font-weight:700;text-decoration:none;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:rgba(0,60,136,.5);border:none;border-radius:2px}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-weight:400;font-size:1.2em;will-change:transform}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:focus,.ol-control button:hover{text-decoration:none;background-color:rgba(0,60,136,.7)}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em)}.ol-attribution ul{margin:0;padding:0 .5em;font-size:.7rem;line-height:1.375em;color:#000;text-shadow:0 0 2px #fff}.ol-attribution li{display:inline;list-style:none;line-height:inherit}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button,.ol-attribution ul{display:inline-block}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution.ol-logo-only ul{display:block}.ol-attribution:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0;height:1.1em;line-height:1em}.ol-attribution.ol-logo-only{background:0 0;bottom:.4em;height:1.1em;line-height:1em}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-logo-only button,.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{top:4.5em;left:.5em;height:200px}.ol-zoomslider button{position:relative;height:10px}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{left:.5em;bottom:.5em}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:inline-block}.ol-overviewmap .ol-overviewmap-map{border:1px solid #7b98bc;height:150px;margin:2px;width:150px}.ol-overviewmap:not(.ol-collapsed) button{bottom:1px;left:2px;position:absolute}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-overviewmap-box{border:2px dotted rgba(0,60,136,.7)}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,998 @@
// OpenLayers 3. See http://openlayers.org/
// License: https://raw.githubusercontent.com/openlayers/ol3/master/LICENSE.md
// Version: v3.17.1
(function (root, factory) {
if (typeof exports === "object") {
module.exports = factory();
} else if (typeof define === "function" && define.amd) {
define([], factory);
} else {
root.ol = factory();
}
}(this, function () {
var OPENLAYERS = {};
var k,aa=this;function t(a,b,c){a=a.split(".");c=c||aa;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c[d]?c=c[d]:c=c[d]={}:c[d]=b}function ba(a){a.Zb=function(){return a.Tg?a.Tg:a.Tg=new a}}
function ca(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function da(a){return"string"==typeof a}function ea(a){return"number"==typeof a}function fa(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}function w(a){return a[ga]||(a[ga]=++ha)}var ga="closure_uid_"+(1E9*Math.random()>>>0),ha=0;function ia(a,b,c){return a.call.apply(a.bind,arguments)}
function ja(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function ka(a,b,c){ka=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ia:ja;return ka.apply(null,arguments)};var la,ma;function y(a,b){a.prototype=Object.create(b.prototype);a.prototype.constructor=a}function na(){}var pa=Function("return this")();var qa=String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")};function ra(a,b){return a<b?-1:a>b?1:0};function sa(a,b,c){return Math.min(Math.max(a,b),c)}var ta=function(){var a;"cosh"in Math?a=Math.cosh:a=function(a){a=Math.exp(a);return(a+1/a)/2};return a}();function ua(a,b,c,d,e,f){var g=e-c,h=f-d;if(0!==g||0!==h){var l=((a-c)*g+(b-d)*h)/(g*g+h*h);1<l?(c=e,d=f):0<l&&(c+=g*l,d+=h*l)}return va(a,b,c,d)}function va(a,b,c,d){a=c-a;b=d-b;return a*a+b*b}function wa(a){return a*Math.PI/180}function xa(a,b){var c=a%b;return 0>c*b?c+b:c}function za(a,b,c){return a+c*(b-a)};function Ba(a){return function(b){if(b)return[sa(b[0],a[0],a[2]),sa(b[1],a[1],a[3])]}}function Ca(a){return a};function Da(a,b,c){this.center=a;this.resolution=b;this.rotation=c};var Ea="function"===typeof Object.assign?Object.assign:function(a,b){if(!a||!a)throw new TypeError("Cannot convert undefined or null to object");for(var c=Object(a),d=1,e=arguments.length;d<e;++d){var f=arguments[d];if(void 0!==f&&null!==f)for(var g in f)f.hasOwnProperty(g)&&(c[g]=f[g])}return c};function Fa(a){for(var b in a)delete a[b]}function Ga(a){var b=[],c;for(c in a)b.push(a[c]);return b}function Ha(a){for(var b in a)return!1;return!b};var Ia="olm_"+(1E4*Math.random()|0);function Ja(a){function b(b){var d=a.listener,e=a.ng||a.target;a.pg&&Ka(a);return d.call(e,b)}return a.og=b}function La(a,b,c,d){for(var e,f=0,g=a.length;f<g;++f)if(e=a[f],e.listener===b&&e.ng===c)return d&&(e.deleteIndex=f),e}function Ma(a,b){var c=a[Ia];return c?c[b]:void 0}function Na(a){var b=a[Ia];b||(b=a[Ia]={});return b}
function Oa(a,b){var c=Ma(a,b);if(c){for(var d=0,e=c.length;d<e;++d)a.removeEventListener(b,c[d].og),Fa(c[d]);c.length=0;if(c=a[Ia])delete c[b],0===Object.keys(c).length&&delete a[Ia]}}function B(a,b,c,d,e){var f=Na(a),g=f[b];g||(g=f[b]=[]);(f=La(g,c,d,!1))?e||(f.pg=!1):(f={ng:d,pg:!!e,listener:c,target:a,type:b},a.addEventListener(b,Ja(f)),g.push(f));return f}function Pa(a,b,c,d){return B(a,b,c,d,!0)}function Qa(a,b,c,d){(a=Ma(a,b))&&(c=La(a,c,d,!0))&&Ka(c)}
function Ka(a){if(a&&a.target){a.target.removeEventListener(a.type,a.og);var b=Ma(a.target,a.type);if(b){var c="deleteIndex"in a?a.deleteIndex:b.indexOf(a);-1!==c&&b.splice(c,1);0===b.length&&Oa(a.target,a.type)}Fa(a)}}function Ra(a){var b=Na(a),c;for(c in b)Oa(a,c)};function Sa(){}Sa.prototype.Gb=!1;function Ta(a){a.Gb||(a.Gb=!0,a.ka())}Sa.prototype.ka=na;function Wa(a,b){this.type=a;this.target=b||null}Wa.prototype.preventDefault=Wa.prototype.stopPropagation=function(){this.to=!0};function Ya(a){a.stopPropagation()}function Za(a){a.preventDefault()};function $a(){this.Ra={};this.Ba={};this.ya={}}y($a,Sa);$a.prototype.addEventListener=function(a,b){var c=this.ya[a];c||(c=this.ya[a]=[]);-1===c.indexOf(b)&&c.push(b)};
$a.prototype.b=function(a){var b="string"===typeof a?new Wa(a):a;a=b.type;b.target=this;var c=this.ya[a],d;if(c){a in this.Ba||(this.Ba[a]=0,this.Ra[a]=0);++this.Ba[a];for(var e=0,f=c.length;e<f;++e)if(!1===c[e].call(this,b)||b.to){d=!1;break}--this.Ba[a];if(0===this.Ba[a]){b=this.Ra[a];for(delete this.Ra[a];b--;)this.removeEventListener(a,na);delete this.Ba[a]}return d}};$a.prototype.ka=function(){Ra(this)};function ab(a,b){return b?b in a.ya:0<Object.keys(a.ya).length}
$a.prototype.removeEventListener=function(a,b){var c=this.ya[a];if(c){var d=c.indexOf(b);a in this.Ra?(c[d]=na,++this.Ra[a]):(c.splice(d,1),0===c.length&&delete this.ya[a])}};function bb(){$a.call(this);this.g=0}y(bb,$a);function cb(a){if(Array.isArray(a))for(var b=0,c=a.length;b<c;++b)Ka(a[b]);else Ka(a)}k=bb.prototype;k.u=function(){++this.g;this.b("change")};k.K=function(){return this.g};k.I=function(a,b,c){if(Array.isArray(a)){for(var d=a.length,e=Array(d),f=0;f<d;++f)e[f]=B(this,a[f],b,c);return e}return B(this,a,b,c)};k.L=function(a,b,c){if(Array.isArray(a)){for(var d=a.length,e=Array(d),f=0;f<d;++f)e[f]=Pa(this,a[f],b,c);return e}return Pa(this,a,b,c)};
k.J=function(a,b,c){if(Array.isArray(a))for(var d=0,e=a.length;d<e;++d)Qa(this,a[d],b,c);else Qa(this,a,b,c)};k.M=cb;function db(a,b,c){Wa.call(this,a);this.key=b;this.oldValue=c}y(db,Wa);function eb(a){bb.call(this);w(this);this.U={};void 0!==a&&this.G(a)}y(eb,bb);var fb={};function gb(a){return fb.hasOwnProperty(a)?fb[a]:fb[a]="change:"+a}k=eb.prototype;k.get=function(a){var b;this.U.hasOwnProperty(a)&&(b=this.U[a]);return b};k.N=function(){return Object.keys(this.U)};k.O=function(){return Ea({},this.U)};function hb(a,b,c){var d;d=gb(b);a.b(new db(d,b,c));a.b(new db("propertychange",b,c))}
k.set=function(a,b,c){c?this.U[a]=b:(c=this.U[a],this.U[a]=b,c!==b&&hb(this,a,c))};k.G=function(a,b){for(var c in a)this.set(c,a[c],b)};k.P=function(a,b){if(a in this.U){var c=this.U[a];delete this.U[a];b||hb(this,a,c)}};function ib(a,b){return a>b?1:a<b?-1:0}function jb(a,b){return 0<=a.indexOf(b)}function kb(a,b,c){var d=a.length;if(a[0]<=b)return 0;if(!(b<=a[d-1]))if(0<c)for(c=1;c<d;++c){if(a[c]<b)return c-1}else if(0>c)for(c=1;c<d;++c){if(a[c]<=b)return c}else for(c=1;c<d;++c){if(a[c]==b)return c;if(a[c]<b)return a[c-1]-b<b-a[c]?c-1:c}return d-1}function lb(a){return a.reduce(function(a,c){return Array.isArray(c)?a.concat(lb(c)):a.concat(c)},[])}
function mb(a,b){var c;c=ca(b);var d="array"==c||"object"==c&&"number"==typeof b.length?b:[b],e=d.length;for(c=0;c<e;c++)a[a.length]=d[c]}function nb(a,b){var c=a.indexOf(b),d=-1<c;d&&a.splice(c,1);return d}function ob(a,b){for(var c=a.length>>>0,d,e=0;e<c;e++)if(d=a[e],b(d,e,a))return d;return null}function pb(a,b){var c=a.length;if(c!==b.length)return!1;for(var d=0;d<c;d++)if(a[d]!==b[d])return!1;return!0}
function qb(a){var b=rb,c=a.length,d=Array(a.length),e;for(e=0;e<c;e++)d[e]={index:e,value:a[e]};d.sort(function(a,c){return b(a.value,c.value)||a.index-c.index});for(e=0;e<a.length;e++)a[e]=d[e].value}function sb(a,b){var c;return a.every(function(d,e){c=e;return!b(d,e,a)})?-1:c};function tb(a){return function(b,c,d){if(void 0!==b)return b=kb(a,b,d),b=sa(b+c,0,a.length-1),a[b]}}function ub(a,b,c){return function(d,e,f){if(void 0!==d)return d=Math.max(Math.floor(Math.log(b/d)/Math.log(a)+(0<f?0:0>f?1:.5))+e,0),void 0!==c&&(d=Math.min(d,c)),b/Math.pow(a,d)}};function vb(a){if(void 0!==a)return 0}function wb(a,b){if(void 0!==a)return a+b}function xb(a){var b=2*Math.PI/a;return function(a,d){if(void 0!==a)return a=Math.floor((a+d)/b+.5)*b}}function yb(){var a=wa(5);return function(b,c){if(void 0!==b)return Math.abs(b+c)<=a?0:b+c}};function zb(a,b){var c=void 0!==b?a.toFixed(b):""+a,d=c.indexOf("."),d=-1===d?c.length:d;return 2<d?c:Array(3-d).join("0")+c}function Ab(a){a=(""+a).split(".");for(var b=["1","3"],c=0;c<Math.max(a.length,b.length);c++){var d=parseInt(a[c]||"0",10),e=parseInt(b[c]||"0",10);if(d>e)return 1;if(e>d)return-1}return 0};function Bb(a,b){a[0]+=b[0];a[1]+=b[1];return a}function Cb(a,b){var c=a[0],d=a[1],e=b[0],f=b[1],g=e[0],e=e[1],h=f[0],f=f[1],l=h-g,m=f-e,c=0===l&&0===m?0:(l*(c-g)+m*(d-e))/(l*l+m*m||0);0>=c||(1<=c?(g=h,e=f):(g+=c*l,e+=c*m));return[g,e]}function Db(a,b,c){a=xa(a+180,360)-180;var d=Math.abs(3600*a);return Math.floor(d/3600)+"\u00b0 "+zb(Math.floor(d/60%60))+"\u2032 "+zb(d%60,c||0)+"\u2033 "+b.charAt(0>a?1:0)}
function Eb(a,b,c){return a?b.replace("{x}",a[0].toFixed(c)).replace("{y}",a[1].toFixed(c)):""}function Fb(a,b){for(var c=!0,d=a.length-1;0<=d;--d)if(a[d]!=b[d]){c=!1;break}return c}function Gb(a,b){var c=Math.cos(b),d=Math.sin(b),e=a[1]*c+a[0]*d;a[0]=a[0]*c-a[1]*d;a[1]=e;return a}function Hb(a,b){var c=a[0]-b[0],d=a[1]-b[1];return c*c+d*d}function Ib(a,b){return Hb(a,Cb(a,b))}function Jb(a,b){return Eb(a,"{x}, {y}",b)};function Kb(a){for(var b=Lb(),c=0,d=a.length;c<d;++c)Mb(b,a[c]);return b}function Ob(a,b,c){return c?(c[0]=a[0]-b,c[1]=a[1]-b,c[2]=a[2]+b,c[3]=a[3]+b,c):[a[0]-b,a[1]-b,a[2]+b,a[3]+b]}function Pb(a,b){return b?(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b):a.slice()}function Rb(a,b,c){b=b<a[0]?a[0]-b:a[2]<b?b-a[2]:0;a=c<a[1]?a[1]-c:a[3]<c?c-a[3]:0;return b*b+a*a}function Sb(a,b){return Tb(a,b[0],b[1])}function Ub(a,b){return a[0]<=b[0]&&b[2]<=a[2]&&a[1]<=b[1]&&b[3]<=a[3]}
function Tb(a,b,c){return a[0]<=b&&b<=a[2]&&a[1]<=c&&c<=a[3]}function Vb(a,b){var c=a[1],d=a[2],e=a[3],f=b[0],g=b[1],h=0;f<a[0]?h|=16:f>d&&(h|=4);g<c?h|=8:g>e&&(h|=2);0===h&&(h=1);return h}function Lb(){return[Infinity,Infinity,-Infinity,-Infinity]}function Wb(a,b,c,d,e){return e?(e[0]=a,e[1]=b,e[2]=c,e[3]=d,e):[a,b,c,d]}function Xb(a,b){var c=a[0],d=a[1];return Wb(c,d,c,d,b)}function Yb(a,b,c,d,e){e=Wb(Infinity,Infinity,-Infinity,-Infinity,e);return Zb(e,a,b,c,d)}
function $b(a,b){return a[0]==b[0]&&a[2]==b[2]&&a[1]==b[1]&&a[3]==b[3]}function ac(a,b){b[0]<a[0]&&(a[0]=b[0]);b[2]>a[2]&&(a[2]=b[2]);b[1]<a[1]&&(a[1]=b[1]);b[3]>a[3]&&(a[3]=b[3]);return a}function Mb(a,b){b[0]<a[0]&&(a[0]=b[0]);b[0]>a[2]&&(a[2]=b[0]);b[1]<a[1]&&(a[1]=b[1]);b[1]>a[3]&&(a[3]=b[1])}function Zb(a,b,c,d,e){for(;c<d;c+=e){var f=a,g=b[c],h=b[c+1];f[0]=Math.min(f[0],g);f[1]=Math.min(f[1],h);f[2]=Math.max(f[2],g);f[3]=Math.max(f[3],h)}return a}
function bc(a,b,c){var d;return(d=b.call(c,cc(a)))||(d=b.call(c,dc(a)))||(d=b.call(c,ec(a)))?d:(d=b.call(c,fc(a)))?d:!1}function gc(a){var b=0;hc(a)||(b=ic(a)*jc(a));return b}function cc(a){return[a[0],a[1]]}function dc(a){return[a[2],a[1]]}function kc(a){return[(a[0]+a[2])/2,(a[1]+a[3])/2]}
function lc(a,b,c,d,e){var f=b*d[0]/2;d=b*d[1]/2;b=Math.cos(c);var g=Math.sin(c);c=f*b;f*=g;b*=d;var h=d*g,l=a[0],m=a[1];a=l-c+h;d=l-c-h;g=l+c-h;c=l+c+h;var h=m-f-b,l=m-f+b,n=m+f+b,f=m+f-b;return Wb(Math.min(a,d,g,c),Math.min(h,l,n,f),Math.max(a,d,g,c),Math.max(h,l,n,f),e)}function jc(a){return a[3]-a[1]}function mc(a,b,c){c=c?c:Lb();nc(a,b)&&(c[0]=a[0]>b[0]?a[0]:b[0],c[1]=a[1]>b[1]?a[1]:b[1],c[2]=a[2]<b[2]?a[2]:b[2],c[3]=a[3]<b[3]?a[3]:b[3]);return c}function fc(a){return[a[0],a[3]]}
function ec(a){return[a[2],a[3]]}function ic(a){return a[2]-a[0]}function nc(a,b){return a[0]<=b[2]&&a[2]>=b[0]&&a[1]<=b[3]&&a[3]>=b[1]}function hc(a){return a[2]<a[0]||a[3]<a[1]}function oc(a,b){var c=(a[2]-a[0])/2*(b-1),d=(a[3]-a[1])/2*(b-1);a[0]-=c;a[2]+=c;a[1]-=d;a[3]+=d}
function pc(a,b,c){a=[a[0],a[1],a[0],a[3],a[2],a[1],a[2],a[3]];b(a,a,2);var d=[a[0],a[2],a[4],a[6]],e=[a[1],a[3],a[5],a[7]];b=Math.min.apply(null,d);a=Math.min.apply(null,e);d=Math.max.apply(null,d);e=Math.max.apply(null,e);return Wb(b,a,d,e,c)};function qc(){return!0}function rc(){return!1};/*
Latitude/longitude spherical geodesy formulae taken from
http://www.movable-type.co.uk/scripts/latlong.html
Licensed under CC-BY-3.0.
*/
function sc(a){this.radius=a}sc.prototype.a=function(a){for(var b=0,c=a.length,d=a[c-1][0],e=a[c-1][1],f=0;f<c;f++)var g=a[f][0],h=a[f][1],b=b+wa(g-d)*(2+Math.sin(wa(e))+Math.sin(wa(h))),d=g,e=h;return b*this.radius*this.radius/2};sc.prototype.b=function(a,b){var c=wa(a[1]),d=wa(b[1]),e=(d-c)/2,f=wa(b[0]-a[0])/2,c=Math.sin(e)*Math.sin(e)+Math.sin(f)*Math.sin(f)*Math.cos(c)*Math.cos(d);return 2*this.radius*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))};
sc.prototype.offset=function(a,b,c){var d=wa(a[1]);b/=this.radius;var e=Math.asin(Math.sin(d)*Math.cos(b)+Math.cos(d)*Math.sin(b)*Math.cos(c));return[180*(wa(a[0])+Math.atan2(Math.sin(c)*Math.sin(b)*Math.cos(d),Math.cos(b)-Math.sin(d)*Math.sin(e)))/Math.PI,180*e/Math.PI]};var tc=new sc(6370997);var uc={};uc.degrees=2*Math.PI*tc.radius/360;uc.ft=.3048;uc.m=1;uc["us-ft"]=1200/3937;
function vc(a){this.cb=a.code;this.c=a.units;this.f=void 0!==a.extent?a.extent:null;this.i=void 0!==a.worldExtent?a.worldExtent:null;this.b=void 0!==a.axisOrientation?a.axisOrientation:"enu";this.g=void 0!==a.global?a.global:!1;this.a=!(!this.g||!this.f);this.o=void 0!==a.getPointResolution?a.getPointResolution:this.sk;this.l=null;this.j=a.metersPerUnit;var b=wc,c=a.code,d=xc||pa.proj4;if("function"==typeof d&&void 0===b[c]){var e=d.defs(c);if(void 0!==e){void 0!==e.axis&&void 0===a.axisOrientation&&
(this.b=e.axis);void 0===a.metersPerUnit&&(this.j=e.to_meter);void 0===a.units&&(this.c=e.units);for(var f in b)b=d.defs(f),void 0!==b&&(a=yc(f),b===e?zc([a,this]):(b=d(f,c),Ac(a,this,b.forward,b.inverse)))}}}k=vc.prototype;k.Sj=function(){return this.cb};k.H=function(){return this.f};k.wb=function(){return this.c};k.$b=function(){return this.j||uc[this.c]};k.Ek=function(){return this.i};k.pl=function(){return this.g};k.ep=function(a){this.g=a;this.a=!(!a||!this.f)};
k.Mm=function(a){this.f=a;this.a=!(!this.g||!a)};k.mp=function(a){this.i=a};k.cp=function(a){this.o=a};k.sk=function(a,b){if("degrees"==this.wb())return a;var c=Bc(this,yc("EPSG:4326")),d=[b[0]-a/2,b[1],b[0]+a/2,b[1],b[0],b[1]-a/2,b[0],b[1]+a/2],d=c(d,d,2),c=tc.b(d.slice(0,2),d.slice(2,4)),d=tc.b(d.slice(4,6),d.slice(6,8)),d=(c+d)/2,c=this.$b();void 0!==c&&(d/=c);return d};k.getPointResolution=function(a,b){return this.o(a,b)};var wc={},Cc={},xc=null;
function zc(a){Dc(a);a.forEach(function(b){a.forEach(function(a){b!==a&&Ec(b,a,Fc)})})}function Gc(){var a=Hc,b=Ic,c=Jc;Kc.forEach(function(d){a.forEach(function(a){Ec(d,a,b);Ec(a,d,c)})})}function Lc(a){wc[a.cb]=a;Ec(a,a,Fc)}function Dc(a){var b=[];a.forEach(function(a){b.push(Lc(a))})}function Mc(a){return a?"string"===typeof a?yc(a):a:yc("EPSG:3857")}function Ec(a,b,c){a=a.cb;b=b.cb;a in Cc||(Cc[a]={});Cc[a][b]=c}function Ac(a,b,c,d){a=yc(a);b=yc(b);Ec(a,b,Nc(c));Ec(b,a,Nc(d))}
function Nc(a){return function(b,c,d){var e=b.length;d=void 0!==d?d:2;c=void 0!==c?c:Array(e);var f,g;for(g=0;g<e;g+=d)for(f=a([b[g],b[g+1]]),c[g]=f[0],c[g+1]=f[1],f=d-1;2<=f;--f)c[g+f]=b[g+f];return c}}function yc(a){var b;if(a instanceof vc)b=a;else if("string"===typeof a){b=wc[a];var c=xc||pa.proj4;void 0===b&&"function"==typeof c&&void 0!==c.defs(a)&&(b=new vc({code:a}),Lc(b))}else b=null;return b}function Oc(a,b){if(a===b)return!0;var c=a.wb()===b.wb();return a.cb===b.cb?c:Bc(a,b)===Fc&&c}
function Pc(a,b){var c=yc(a),d=yc(b);return Bc(c,d)}function Bc(a,b){var c=a.cb,d=b.cb,e;c in Cc&&d in Cc[c]&&(e=Cc[c][d]);void 0===e&&(e=Qc);return e}function Qc(a,b){if(void 0!==b&&a!==b){for(var c=0,d=a.length;c<d;++c)b[c]=a[c];a=b}return a}function Fc(a,b){var c;if(void 0!==b){c=0;for(var d=a.length;c<d;++c)b[c]=a[c];c=b}else c=a.slice();return c}function Rc(a,b,c){return Pc(b,c)(a,void 0,a.length)}function Sc(a,b,c){b=Pc(b,c);return pc(a,b)};function Tc(){eb.call(this);this.v=Lb();this.A=-1;this.l={};this.s=this.o=0}y(Tc,eb);k=Tc.prototype;k.vb=function(a,b){var c=b?b:[NaN,NaN];this.sb(a[0],a[1],c,Infinity);return c};k.sg=function(a){return this.Bc(a[0],a[1])};k.Bc=rc;k.H=function(a){this.A!=this.g&&(this.v=this.Od(this.v),this.A=this.g);var b=this.v;a?(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3]):a=b;return a};k.Bb=function(a){return this.od(a*a)};k.jb=function(a,b){this.rc(Pc(a,b));return this};function Uc(a){this.length=a.length||a;for(var b=0;b<this.length;b++)this[b]=a[b]||0}Uc.prototype.BYTES_PER_ELEMENT=4;Uc.prototype.set=function(a,b){b=b||0;for(var c=0;c<a.length&&b+c<this.length;c++)this[b+c]=a[c]};Uc.prototype.toString=Array.prototype.join;"undefined"==typeof Float32Array&&(Uc.BYTES_PER_ELEMENT=4,Uc.prototype.BYTES_PER_ELEMENT=Uc.prototype.BYTES_PER_ELEMENT,Uc.prototype.set=Uc.prototype.set,Uc.prototype.toString=Uc.prototype.toString,t("Float32Array",Uc,void 0));function Vc(a){this.length=a.length||a;for(var b=0;b<this.length;b++)this[b]=a[b]||0}Vc.prototype.BYTES_PER_ELEMENT=8;Vc.prototype.set=function(a,b){b=b||0;for(var c=0;c<a.length&&b+c<this.length;c++)this[b+c]=a[c]};Vc.prototype.toString=Array.prototype.join;if("undefined"==typeof Float64Array){try{Vc.BYTES_PER_ELEMENT=8}catch(a){}Vc.prototype.BYTES_PER_ELEMENT=Vc.prototype.BYTES_PER_ELEMENT;Vc.prototype.set=Vc.prototype.set;Vc.prototype.toString=Vc.prototype.toString;t("Float64Array",Vc,void 0)};function Wc(a,b,c,d,e){a[0]=b;a[1]=c;a[2]=d;a[3]=e};function Xc(){var a=Array(16);Yc(a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return a}function Zc(){var a=Array(16);Yc(a,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return a}function Yc(a,b,c,d,e,f,g,h,l,m,n,p,q,r,u,x,v){a[0]=b;a[1]=c;a[2]=d;a[3]=e;a[4]=f;a[5]=g;a[6]=h;a[7]=l;a[8]=m;a[9]=n;a[10]=p;a[11]=q;a[12]=r;a[13]=u;a[14]=x;a[15]=v}
function $c(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15]}function ad(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1}
function bd(a,b,c){var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],l=a[5],m=a[6],n=a[7],p=a[8],q=a[9],r=a[10],u=a[11],x=a[12],v=a[13],D=a[14];a=a[15];var A=b[0],z=b[1],F=b[2],N=b[3],K=b[4],X=b[5],oa=b[6],H=b[7],ya=b[8],Ua=b[9],Xa=b[10],Va=b[11],Aa=b[12],Qb=b[13],Nb=b[14];b=b[15];c[0]=d*A+h*z+p*F+x*N;c[1]=e*A+l*z+q*F+v*N;c[2]=f*A+m*z+r*F+D*N;c[3]=g*A+n*z+u*F+a*N;c[4]=d*K+h*X+p*oa+x*H;c[5]=e*K+l*X+q*oa+v*H;c[6]=f*K+m*X+r*oa+D*H;c[7]=g*K+n*X+u*oa+a*H;c[8]=d*ya+h*Ua+p*Xa+x*Va;c[9]=e*ya+l*Ua+q*Xa+v*Va;c[10]=f*
ya+m*Ua+r*Xa+D*Va;c[11]=g*ya+n*Ua+u*Xa+a*Va;c[12]=d*Aa+h*Qb+p*Nb+x*b;c[13]=e*Aa+l*Qb+q*Nb+v*b;c[14]=f*Aa+m*Qb+r*Nb+D*b;c[15]=g*Aa+n*Qb+u*Nb+a*b}
function cd(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],l=a[6],m=a[7],n=a[8],p=a[9],q=a[10],r=a[11],u=a[12],x=a[13],v=a[14],D=a[15],A=c*h-d*g,z=c*l-e*g,F=c*m-f*g,N=d*l-e*h,K=d*m-f*h,X=e*m-f*l,oa=n*x-p*u,H=n*v-q*u,ya=n*D-r*u,Ua=p*v-q*x,Xa=p*D-r*x,Va=q*D-r*v,Aa=A*Va-z*Xa+F*Ua+N*ya-K*H+X*oa;0!=Aa&&(Aa=1/Aa,b[0]=(h*Va-l*Xa+m*Ua)*Aa,b[1]=(-d*Va+e*Xa-f*Ua)*Aa,b[2]=(x*X-v*K+D*N)*Aa,b[3]=(-p*X+q*K-r*N)*Aa,b[4]=(-g*Va+l*ya-m*H)*Aa,b[5]=(c*Va-e*ya+f*H)*Aa,b[6]=(-u*X+v*F-D*z)*Aa,b[7]=(n*X-q*F+r*z)*Aa,
b[8]=(g*Xa-h*ya+m*oa)*Aa,b[9]=(-c*Xa+d*ya-f*oa)*Aa,b[10]=(u*K-x*F+D*A)*Aa,b[11]=(-n*K+p*F-r*A)*Aa,b[12]=(-g*Ua+h*H-l*oa)*Aa,b[13]=(c*Ua-d*H+e*oa)*Aa,b[14]=(-u*N+x*z-v*A)*Aa,b[15]=(n*N-p*z+q*A)*Aa)}function dd(a,b,c){var d=a[1]*b+a[5]*c+0*a[9]+a[13],e=a[2]*b+a[6]*c+0*a[10]+a[14],f=a[3]*b+a[7]*c+0*a[11]+a[15];a[12]=a[0]*b+a[4]*c+0*a[8]+a[12];a[13]=d;a[14]=e;a[15]=f}
function ed(a,b,c){Yc(a,a[0]*b,a[1]*b,a[2]*b,a[3]*b,a[4]*c,a[5]*c,a[6]*c,a[7]*c,1*a[8],1*a[9],1*a[10],1*a[11],a[12],a[13],a[14],a[15])}function fd(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],l=a[6],m=a[7],n=Math.cos(b),p=Math.sin(b);a[0]=c*n+g*p;a[1]=d*n+h*p;a[2]=e*n+l*p;a[3]=f*n+m*p;a[4]=c*-p+g*n;a[5]=d*-p+h*n;a[6]=e*-p+l*n;a[7]=f*-p+m*n}new Float64Array(3);new Float64Array(3);new Float64Array(4);new Float64Array(4);new Float64Array(4);new Float64Array(16);function gd(a,b,c,d,e,f){var g=e[0],h=e[1],l=e[4],m=e[5],n=e[12];e=e[13];for(var p=f?f:[],q=0;b<c;b+=d){var r=a[b],u=a[b+1];p[q++]=g*r+l*u+n;p[q++]=h*r+m*u+e}f&&p.length!=q&&(p.length=q);return p};function hd(){Tc.call(this);this.f="XY";this.a=2;this.B=null}y(hd,Tc);function id(a){if("XY"==a)return 2;if("XYZ"==a||"XYM"==a)return 3;if("XYZM"==a)return 4}k=hd.prototype;k.Bc=rc;k.Od=function(a){return Yb(this.B,0,this.B.length,this.a,a)};k.Ib=function(){return this.B.slice(0,this.a)};k.la=function(){return this.B};k.Jb=function(){return this.B.slice(this.B.length-this.a)};k.Kb=function(){return this.f};
k.od=function(a){this.s!=this.g&&(Fa(this.l),this.o=0,this.s=this.g);if(0>a||0!==this.o&&a<=this.o)return this;var b=a.toString();if(this.l.hasOwnProperty(b))return this.l[b];var c=this.Nc(a);if(c.la().length<this.B.length)return this.l[b]=c;this.o=a;return this};k.Nc=function(){return this};k.va=function(){return this.a};function jd(a,b,c){a.a=id(b);a.f=b;a.B=c}
function kd(a,b,c,d){if(b)c=id(b);else{for(b=0;b<d;++b){if(0===c.length){a.f="XY";a.a=2;return}c=c[0]}c=c.length;b=2==c?"XY":3==c?"XYZ":4==c?"XYZM":void 0}a.f=b;a.a=c}k.rc=function(a){this.B&&(a(this.B,this.B,this.a),this.u())};k.rotate=function(a,b){var c=this.la();if(c){for(var d=c.length,e=this.va(),f=c?c:[],g=Math.cos(a),h=Math.sin(a),l=b[0],m=b[1],n=0,p=0;p<d;p+=e){var q=c[p]-l,r=c[p+1]-m;f[n++]=l+q*g-r*h;f[n++]=m+q*h+r*g;for(q=p+2;q<p+e;++q)f[n++]=c[q]}c&&f.length!=n&&(f.length=n);this.u()}};
k.Sc=function(a,b){var c=this.la();if(c){var d=c.length,e=this.va(),f=c?c:[],g=0,h,l;for(h=0;h<d;h+=e)for(f[g++]=c[h]+a,f[g++]=c[h+1]+b,l=h+2;l<h+e;++l)f[g++]=c[l];c&&f.length!=g&&(f.length=g);this.u()}};function ld(a,b,c,d){for(var e=0,f=a[c-d],g=a[c-d+1];b<c;b+=d)var h=a[b],l=a[b+1],e=e+(g*h-f*l),f=h,g=l;return e/2}function md(a,b,c,d){var e=0,f,g;f=0;for(g=c.length;f<g;++f){var h=c[f],e=e+ld(a,b,h,d);b=h}return e};function nd(a,b,c,d,e,f,g){var h=a[b],l=a[b+1],m=a[c]-h,n=a[c+1]-l;if(0!==m||0!==n)if(f=((e-h)*m+(f-l)*n)/(m*m+n*n),1<f)b=c;else if(0<f){for(e=0;e<d;++e)g[e]=za(a[b+e],a[c+e],f);g.length=d;return}for(e=0;e<d;++e)g[e]=a[b+e];g.length=d}function od(a,b,c,d,e){var f=a[b],g=a[b+1];for(b+=d;b<c;b+=d){var h=a[b],l=a[b+1],f=va(f,g,h,l);f>e&&(e=f);f=h;g=l}return e}function pd(a,b,c,d,e){var f,g;f=0;for(g=c.length;f<g;++f){var h=c[f];e=od(a,b,h,d,e);b=h}return e}
function qd(a,b,c,d,e,f,g,h,l,m,n){if(b==c)return m;var p;if