I am adding a new column with the following script, however, the column is coming without a border on the right hand side.
How can I set a BLACK border on the right hand side?
var mytable = reportContext.getDesignHandle().findElement(tableName);
var colbinds = mytable.getColumnBindings( );
var cs1 = StructureFactory.createComputedColumn( );
cs1.setName("Q2");
cs1.setExpression( "dataSetRow[\"Q2\"]" );
colbinds.addItem( cs1 );
//second parameter is before(-1) or after(1)
mytable.insertColumn(2,1);
//get header and add label
var myheader = mytable.getHeader( ).get( 0 );
tcell = myheader.getCells( ).get( 2 );
var mylabel = elementFactory.newLabel( null );
mylabel.setText( "Number of Responses (2010 Sites)" );//$NON-NLS-1$
tcell.getContent( ).add( mylabel );
//tcell.getStyle().borderRightColor = "Black"?
//get first detail row
mydetail = mytable.getDetail( ).get( 0 );
//get first column and add detail data item
var tcell = mydetail.getCells( ).get( 2 );
var mydata = elementFactory.newDataItem( null );
mydata.setResultSetColumn( "Q2");
tcell.getContent( ).add( mydata );
//tcell.getStyle().borderRightColor = "Black"?
You should set style also:
tcell.getStyle().borderRightColor = "Black";
tcell.getStyle().borderRightStyle = "solid";
and optionally:
tcell.getStyle().borderRightWidth = "1pt";
Related
I am using the Charts library for displaying a line chart in my app
However, the chart is not displaying correctly when there are only three points available
See the attached screenshots below. Thanks in advance.
I want this type of chart
but results get this type
See Below my code for reference
I am using this library:-
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
chartView?.invalidate()
chartView?.setViewPortOffsets(0f, 0f, 0f, 0f)
chartView?.description?.isEnabled = false
chartView?.setTouchEnabled(true)
chartView?.isDragEnabled = true
chartView?.setScaleEnabled(false)
chartView?.setPinchZoom(false)
chartView?.setDrawGridBackground(false)
chartView?.maxHighlightDistance = 300f
val x: XAxis? = chartView?.xAxis
x?.isEnabled = Valse
val y = chartView?.axisLeft
y?.setLabelCount(0, false)
y?.isEnabled = false
y?.textColor = Color.GRAY
y?.setDrawGridLines(false)
y?.axisLineColor = Color.BLACK
chartView?.axisLeft?.axisMinimum = 0f
chartView?.axisRight?.axisMinimum = 0f
chartView?.axisRight?.isEnabled = false
chartView?.legend?.isEnabled = false
val values = ArrayList<Entry>()
values.add(Entry(0f, 4836.62f))
values.add(Entry(1f, 4856.41f))
values.add(Entry(2f, 4940.18f))
val set1: LineDataSet
if (chartView?.data != null &&
chartView.data!!.dataSetCount > 0
) {
set1 = chartView.data.getDataSetByIndex(0) as LineDataSet
set1.values = values
chartView.data.notifyDataChanged()
chartView.notifyDataSetChanged()
chartView.invalidate()
} else {
// create a dataset and give it a type
set1 = LineDataSet(values, "")
set1.mode = LineDataSet.Mode.CUBIC_BEZIER
set1.cubicIntensity = 0.2f
set1.setDrawFilled(false)
set1.setDrawCircles(false)
set1.lineWidth = 1.5f
set1.color = ContextCompat.getColor(activity, R.color.colorPrimary)
indexValue?.text = arrIndexList?.last()?.indexValue.toString()
change?.text = arrIndexList?.last()?.change.toString()
changePercent?.text = arrIndexList?.last()?.changePercent.toString()
val data = LineData(set1)
data.setValueTextSize(9f)
data.setDrawValues(false)
chartView?.data = data
chartView?.animateX(1500)
}
I have tried numerous ways and followed some of the examples that are scattered around the web on how to write a jagged array (an array of arrays that may be of differing lengths) in HDF5.
Most of the examples are in C and rather low-level. Anyhow I can't seem to get it working and I just looked at the C-source code and it pretty much says that any variable-length datatypes that are not strings are not supported (if I understood correctly).
My miserable dysfunctional code (as is):
public void WIP_createVLenFloatDataSet( List<? extends Number> floats ) throws Exception
{
String group = "/test";
long groupId = createGroupIfNotExist( group );
MDataQualifier qualifier = new MDataQualifierImpl( group, "float", "0.0.0" );
long datasetId = openDataSet( qualifier );
long heapType = H5.H5Tcopy( MDataType.FLOAT_ARRAY.getHDFType() );
heapType = H5.H5Tvlen_create( heapType );
// heapType = H5.H5Tarray_create( heapType, 1, new long[]{1} );
if( !exists( datasetId ) )
{
long[] maxDims = new long[]{ HDF5Constants.H5S_UNLIMITED };
long dataspaceId = H5.H5Screate_simple( 1, new long[]{ 1 }, null );
// Create the dataset.
long datasetId1 = -1;
try
{
if( exists( m_fileId ) && exists( dataspaceId ) && exists( heapType ) )
{
long creationProperties = H5.H5Pcreate( HDF5Constants.H5P_DATASET_CREATE );
H5.H5Pset_chunk( creationProperties, /*ndims*/1, new long[]{ 1 } );
datasetId1 = H5.H5Dcreate( groupId, qualifier.getVersionedName(), heapType, dataspaceId, H5P_DEFAULT, creationProperties, H5P_DEFAULT );
// H5.H5Pclose( creationProperties );
}
}
catch( Exception e )
{
LOG.error( "Problems creating the dataset: " + e.getMessage(), e );
}
datasetId = datasetId1;
if( exists( datasetId ) )
{
// flushIfNecessary();
LOG.trace( "Wrote empty dataset {}", qualifier.getVersionedName() );
}
}
List<? extends Number> data = ( List<? extends Number> )floats;
// H5.H5Dwrite( datasetId, heapType, dataspaceId, memSpaceId, HDF5Constants.H5P_DEFAULT, Floats.toArray( data) );
ByteBuffer bb = ByteBuffer.allocate( data.size() * 4 );
floats.forEach( f -> bb.putFloat( f.floatValue() ) );
// H5.H5Dwrite( datasetId, heapType, H5S_ALL, H5S_ALL, H5P_DEFAULT, Floats.toArray( data ) );
H5.H5Dwrite( datasetId, heapType, H5S_ALL, H5S_ALL, H5P_DEFAULT, bb.array() );
}
Has anyone done this before and can at least confirm that it's not possible?
The most I can get out of HDF5 is the message "buf does not support variable length type".
Apparently the "glue code" of the JNI wrapper doesn't support this. If you want to use this feature you either have to implement your own JNI or wait for a newer version. The official JNI code is open source and can be found here.
Lets see what we have. First file [Interface Class]:
list arrayList
list linkedList
Second file[Class countOfInstanse]:
arrayList 120
linkedList 4
I would like to join this two files by key[Class] and get count per each Interface:
list 124
and code:
public class Main
{
public static void main( String[] args )
{
String docPath = args[ 0 ];
String wcPath = args[ 1 ];
String stopPath = args[ 2 ];
Properties properties = new Properties();
AppProps.setApplicationJarClass( properties, Main.class );
AppProps.setApplicationName( properties, "Part 1" );
AppProps.addApplicationTag( properties, "lets:do:it" );
AppProps.addApplicationTag( properties, "technology:Cascading" );
FlowConnector flowConnector = new Hadoop2MR1FlowConnector( properties );
// create source and sink taps
Tap docTap = new Hfs( new TextDelimited( true, "\t" ), docPath );
Tap wcTap = new Hfs( new TextDelimited( true, "\t" ), wcPath );
Fields stop = new Fields( "class" );
Tap classTap = new Hfs( new TextDelimited( true, "\t" ), stopPath );
// specify a regex operation to split the "document" text lines into a token stream
Fields token = new Fields( "token" );
Fields text = new Fields( "interface" );
RegexSplitGenerator splitter = new RegexSplitGenerator( token, "[ \\[\\]\\(\\),.]" );
Fields fieldSelector = new Fields( "interface", "class" );
Pipe docPipe = new Each( "token", text, splitter, fieldSelector );
// define "ScrubFunction" to clean up the token stream
Fields scrubArguments = new Fields( "interface", "class" );
docPipe = new Each( docPipe, scrubArguments, new ScrubFunction( scrubArguments ), Fields.RESULTS );
Fields text1 = new Fields( "amount" );
// RegexSplitGenerator splitter = new RegexSplitGenerator( token, "[ \\[\\]\\(\\),.]" );
Fields fieldSelector1 = new Fields( "class", "amount" );
Pipe stopPipe = new Each( "token1", text1, splitter, fieldSelector1 );
Pipe tokenPipe = new CoGroup( docPipe, token, stopPipe, text, new InnerJoin() );
tokenPipe = new Each( tokenPipe, text, new RegexFilter( "^$" ) );
// determine the word counts
Pipe wcPipe = new Pipe( "wc", tokenPipe );
wcPipe = new Retain( wcPipe, token );
wcPipe = new GroupBy( wcPipe, token );
wcPipe = new Every( wcPipe, Fields.ALL, new Count(), Fields.ALL );
// connect the taps, pipes, etc., into a flow
FlowDef flowDef = FlowDef.flowDef().setName( "wc" ).addSource( docPipe, docTap ).addSource( stopPipe, classTap ).addTailSink( wcPipe, wcTap );
// write a DOT file and run the flow
Flow wcFlow = flowConnector.connect( flowDef );
wcFlow.writeDOT( "dot/wc.dot" );
wcFlow.complete();
}
}
[I decided to resolve this issue step-by-step and left final result here for others. So first step - Couldn`t join two files with one key via Cascading (Not Completed yet) ]
I would convert the two files to two Map objects, iterate through the keys and sum up the numbers. Then you can write them back to a file.
Map<String,String> nameToType = new HashMap<String,String>();
Map<String,Integer> nameToCount = new HashMap<String,Integer>();
//fill Maps from file here
Map<String,Integer> result = new HashMap<String,Integer>();
for (String name: nameToType.keyset())
{
String type = nameToType.get(name);
int count = nameToCount.get(type);
if (!result.containsKey(type))
result.put(type,0);
result.put(type, result.get(type) + count);
}
I would like to get a table header like this:
But I'm able to get only column header without the third row (y1, y2, y3). How can I do that?
I have something like this so far:
protected ILayer createColumnHeaderLayer(IDataProvider dataProvider,
ILayer bodyLayer,
IUniqueIndexLayer dataLayer,
SelectionLayer selectionLayer) {
IDataProvider columnHeaderDataProvider = new TeppichDiagramHeaderDataProvider(dataProvider);
DataLayer columnBaseLayer = new DataLayer(
columnHeaderDataProvider,
DataLayer.DEFAULT_COLUMN_WIDTH,
30
);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnBaseLayer, bodyLayer, selectionLayer, false);
ColumnGroupModel columnGroupModel = new ColumnGroupModel();
ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(
columnHeaderLayer,
selectionLayer,
columnGroupModel,
false
);
columnGroupHeaderLayer.addColumnsIndexesToGroup(
"Group",
3, 4, 5
);
return columnGroupHeaderLayer;
}
where TeppichDiagramHeaderDataProvider is a dataprovider for the column header. Where it returns 1 from its getRowCount() method.
I am new to gui in java, i spent 3
hours trying to figure out what i have done wrong or misunderstood, i should get this:
but the text in my code is displayed after textfields
textPanel = new JPanel();
textPanel.setLayout(new GridLayout(3,0));
fName = new JTextField( 15 ) ;
textPanel.add(fName);
jlbName = new JLabel ( "Firstname" );
jlbName.setHorizontalAlignment(JLabel.RIGHT);
textPanel.add(jlbName);
lName = new JTextField( 15 ) ;
textPanel.add(lName);
jlbName = new JLabel ( "LastName" );
jlbName.setHorizontalAlignment(JLabel.RIGHT);
textPanel.add(jlbName);
libNo = new JTextField( 15 ) ;
textPanel.add(libNo);
libNo.setEditable(false);
jlbName = new JLabel ( "Library Number" );
jlbName.setHorizontalAlignment(JLabel.RIGHT);
textPanel.add(jlbName);
add(textPanel,BorderLayout.EAST);
JButton jbtN = new JButton("Add borrower");
add(jbtN ,BorderLayout.SOUTH);
You are inserting the components into the panel in the wrong order. You first insert the text fields and later the labels. Do the opposite, i.e. instead of:
textPanel.add(fName);
...
textPanel.add(jlbName);
...
do:
textPanel.add(jlbName);
...
textPanel.add(fName);
...