public class TopcatUtils extends Object
Modifier and Type | Field and Description |
---|---|
static uk.ac.starlink.table.ValueInfo |
COLID_INFO
Column auxiliary metadata key identifying the uniqe column identifier
for use in algebraic expressions.
|
static String |
DEMO_LOCATION |
static String |
DEMO_NODES |
static String |
DEMO_TABLE |
static uk.ac.starlink.table.ValueInfo |
EXPR_INFO
Column auxiliary metadata key identifying the text string which
gives an expression for a synthetic column.
|
static uk.ac.starlink.table.ValueInfo |
NUMERIC_CONVERTER_INFO
Column auxiliary metadata key identifying an object which can convert
from non-numeric cell values to numeric ones.
|
static String |
STATUS_URL |
static uk.ac.starlink.table.ValueInfo |
TIME_INFO
Data identifier for epoch-type data.
|
static String |
VERSION_RESOURCE |
Constructor and Description |
---|
TopcatUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addSubset(JComponent parent,
TopcatModel tcModel,
BitSet matchMask,
String dfltName,
String[] msgLines,
String title)
Using input from the user, adds a new (or reused) Row Subset
to the given TopcatModel based on a given BitSet.
|
static void |
alignComponents(JComponent[] comps)
Reshapes a set of components so that they all have the same
preferred size (that of the largest one).
|
static boolean |
canJel()
Indicates if it's possible to use JEL to compile algebraic expressions.
|
static TopcatModel |
decodeSession(uk.ac.starlink.table.StarTable table,
String location,
ControlWindow controlWindow)
Attempts to unpack a StarTable into a TopcatModel containing
per-table application session information.
|
static uk.ac.starlink.table.StarTable |
encodeSession(TopcatModel tcModel)
Encodes a TopcatModel as a StarTable including per-table session
information, suitable for serialization.
|
static void |
enquireLatestVersion()
Ascertains the most recent release using an external connection,
and reports through the logging system as appropriate.
|
static void |
ensureRowIndexIsVisible(JTable jtab,
int irow)
Scrolls a JTable as necessary to ensure that a given row index
is scrolled to the visible part of the viewport.
|
static boolean |
equals(Object o1,
Object o2)
Determines whether two objects are equal in the sense of
Object.equals(java.lang.Object) . |
static String |
formatLong(long num)
Formats a long value for presentation as text.
|
static String[] |
getAbout()
Returns some lines of text describing this copy of the software
including its version and versions of some important components.
|
static String |
getApplicationName()
Returns the name of this application.
|
static String |
getBaseName(String origName,
String baseSuffix)
Returns the base name of a column; that is one without any
suffix based on
baseSuffix . |
static Desktop |
getBrowserDesktop()
Returns a browse-capable desktop instance, or null if none is available.
|
static String |
getDistinctName(ColumnList colList,
String origName,
String baseSuffix)
Returns a column name based on a given one which is guaranteed
distinct from any others in the column list.
|
static java.util.function.Consumer<URL> |
getDocUrlHandler()
Returns an object that will take documentation-type URLs
and display them somehow, probably in an external browser window.
|
static String |
getExpression(uk.ac.starlink.table.ColumnInfo info)
Returns the expression text for a column.
|
static String |
getRevision()
Returns the version control revision number
for TOPCAT and its dependencies.
|
static List<uk.ac.starlink.table.DescribedValue> |
getRowAsParameters(TopcatModel tcModel,
long lrow)
Returns the values from a row of a given table as a list of
DescribedValues, suitable for use as parameters (per-value metadata)
of a StarTable.
|
static uk.ac.starlink.table.StarTable |
getSaveTable(TopcatModel tcModel)
Returns the table represented by the current state of a given
TopcatModel in a form suitable for persisting into one of the
known serialization formats.
|
static String |
getSTILVersion()
Returns the version string for the version of STIL being used here.
|
static String |
getVersion()
Returns the version string for this copy of TOPCAT.
|
static String |
identityString(Object obj)
Returns a string unique to an object's identity.
|
static void |
memoryError(OutOfMemoryError e)
Alerts the user that the system has run out of memory, and provides
the option of some useful tips.
|
static void |
memoryErrorLater(OutOfMemoryError e)
Queues a
memoryError(java.lang.OutOfMemoryError) call for later execution on the
event dispatch thread. |
static boolean |
setAboutHandler(Runnable doAbout)
Invokes the java.awt.Desktop.setAboutHandler method.
|
static void |
setClipboardText(String txt)
Sets the text content of the system clipboard(s).
|
static void |
showAbout(Component parent)
Displays an informational About TOPCAT window.
|
public static String DEMO_LOCATION
public static String DEMO_TABLE
public static String DEMO_NODES
public static final String VERSION_RESOURCE
public static final String STATUS_URL
public static final uk.ac.starlink.table.ValueInfo COLID_INFO
public static final uk.ac.starlink.table.ValueInfo EXPR_INFO
public static final uk.ac.starlink.table.ValueInfo NUMERIC_CONVERTER_INFO
public static final uk.ac.starlink.table.ValueInfo TIME_INFO
public static uk.ac.starlink.table.StarTable getSaveTable(TopcatModel tcModel)
This basicaly uses TopcatModel.getApparentStarTable()
,
but may apply a few extra tweaks for a table that is known to be
about to be saved.
tcModel
- topcat modelpublic static String getExpression(uk.ac.starlink.table.ColumnInfo info)
info
- column infopublic static String getBaseName(String origName, String baseSuffix)
baseSuffix
.
This method is used in conjunction with getDistinctName(uk.ac.starlink.topcat.ColumnList, java.lang.String, java.lang.String)
.origName
- full name, possibly including bits of suffixbaseSuffix
- the base suffix stringbaseSuffix
public static String getDistinctName(ColumnList colList, String origName, String baseSuffix)
origName
is already unique, it may be
returned. Otherwise a new name may be made which involves appending
the given baseSuffix
to it.colList
- column list within which distinct naming is requiredorigName
- initial namebaseSuffix
- suffix used for deduplicationorigName
which is not the same
as any existing column names in colList
getBaseName(java.lang.String, java.lang.String)
public static String getApplicationName()
public static String[] getAbout()
public static java.util.function.Consumer<URL> getDocUrlHandler()
public static List<uk.ac.starlink.table.DescribedValue> getRowAsParameters(TopcatModel tcModel, long lrow)
tcModel
- table supplying valueslrow
- row indexpublic static void setClipboardText(String txt)
txt
- text to set as clipboard contentspublic static void ensureRowIndexIsVisible(JTable jtab, int irow)
jtab
- JTableirow
- table index that must be visibleJList.ensureIndexIsVisible(int)
public static void memoryError(OutOfMemoryError e)
e
- exception, or nullpublic static void memoryErrorLater(OutOfMemoryError e)
memoryError(java.lang.OutOfMemoryError)
call for later execution on the
event dispatch thread.e
- exception, or nullpublic static boolean canJel()
This used to query the SecurityManager, but the
java.lang.SecurityManager
class is
deprecated for removal in later JREs, and I don't think it's
likely that expression compilation will be blocked.
So this method currently returns true unconditionally,
but retain it in case it turns out there are circumstances
we can test for that bear on this.
public static Desktop getBrowserDesktop()
public static String getVersion()
public static String getRevision()
public static String getSTILVersion()
public static void enquireLatestVersion()
public static boolean equals(Object o1, Object o2)
Object.equals(java.lang.Object)
. Unlike that method however,
it returns true if both objects are null
, and
won't throw a NullPointerException.o1
- first objecto2
- second objecto1.equals(o2)
or they're both nullpublic static String identityString(Object obj)
obj
- objectpublic static String formatLong(long num)
num
- number to formatpublic static void alignComponents(JComponent[] comps)
comps
- components to alignpublic static void showAbout(Component parent)
parent
- parent componentpublic static boolean setAboutHandler(Runnable doAbout)
If the target platform is upgraded one day to Java >= 9, this reflective code can be eliminated or replaced by something very much simpler.
doAbout
- callback to display an About Application windowpublic static void addSubset(JComponent parent, TopcatModel tcModel, BitSet matchMask, String dfltName, String[] msgLines, String title)
parent
- parent component for dialoguetcModel
- topcat modelmatchMask
- mask for included rowsdfltName
- default name for subsetmsgLines
- lines of text to appear in dialogue windowtitle
- dialogue window titlepublic static uk.ac.starlink.table.StarTable encodeSession(TopcatModel tcModel)
tcModel
- modelpublic static TopcatModel decodeSession(uk.ac.starlink.table.StarTable table, String location, ControlWindow controlWindow)
table
- encoded tablelocation
- table location stringcontrolWindow
- control window, or null if necessaryCopyright © 2003-2025 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.