How to fill screen with items by using TableLayoutManager - blackberry

I try to implement the third example at the link : http://devblog.blackberry.com/2009/10/how-to-use-table-view-layout/
I made a simple app to try the layout, but items do not fill the screen and stays at left side of it. I want to have the exact view of the screenshot at the example link. However my app looks like this :
I want the innerTable items on the right side as I pointed at the screenshot.
here is my code :
TableLayoutManager outerTable = new TableLayoutManager(new int[]{
TableLayoutManager.USE_PREFERRED_SIZE,
TableLayoutManager.SPLIT_REMAINING_WIDTH
},USE_ALL_WIDTH);
TableLayoutManager innerTable = new TableLayoutManager(new int[]{
TableLayoutManager.USE_PREFERRED_SIZE,
TableLayoutManager.USE_PREFERRED_SIZE
},TableLayoutManager.USE_ALL_WIDTH);
TableLayoutManager innerTable2 = new TableLayoutManager(new int[]{
TableLayoutManager.USE_PREFERRED_SIZE,
TableLayoutManager.USE_PREFERRED_SIZE
},0);
innerTable.add(new LabelField("titleField"));
innerTable.add(new LabelField("title"));
innerTable.add(new LabelField("descriptionfield"));
innerTable.add(new LabelField("description"));
innerTable.add(new LabelField("rating field"));
innerTable.add(new LabelField("***"));
outerTable.add(new BitmapField(Bitmap.getBitmapResource("testimg.png"),Field.FOCUSABLE));
outerTable.add(innerTable);
innerTable2.add(new LabelField("titleField"));
innerTable2.add(new LabelField("title"));
innerTable2.add(new LabelField("descriptionfield"));
innerTable2.add(new LabelField("description"));
innerTable2.add(new LabelField("rating field"));
innerTable2.add(new LabelField("***"));
outerTable.add(new BitmapField(Bitmap.getBitmapResource("testimg.png"),Field.FOCUSABLE));
outerTable.add(innerTable2);
add(outerTable);
Do you have any idea ?
Thanks

Try playing with each field alignment flags. for instance:
innerTable2.add(new LabelField("titleField", DrawStyle.RIGHT | Field.USE_ALL_WIDTH));

Related

How to create helical curve using inventor api and c# or vb.net

I have code in c# windows app creating a line in a 2D sketch. And then I created a 3D sketch. Eventually I want to add a helical curve around this line from the 3D sketch. Can anyone help me please to solve this issue? Thanks in advance.
public void MyMethod(Inventor.Application ThisApplication)
{
PartDocument oSheetMetalDoc = (PartDocument)m_oInventorApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, m_oInventorApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject, SystemOfMeasureEnum.kMetricSystemOfMeasure, DraftingStandardEnum.kDefault_DraftingStandard, "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"), true);
// Set a reference to the component definition.
SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oSheetMetalDoc.ComponentDefinition;
// Set a reference to the sheet
// metal features collection.
SheetMetalFeatures oSheetMetalFeatures = (SheetMetalFeatures)oCompDef.Features;
// Create a new sketch on the X-Y work plane.
PlanarSketch oSketch = default(PlanarSketch);
oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes[3]);
TransientGeometry oTransGeom = (TransientGeometry)ThisApplication.TransientGeometry;
// Draw a 4cm x 3cm rectangle with the
// corner at (0,0)
SketchLine line = (SketchLine)oSketch.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, 0), oTransGeom.CreatePoint2d(0, 500)); // 2. ihtimal
// skecth line turn to centerline
line.Centerline = true;
ThisApplication.ActiveView.GoHome();
// Create a 3D sketch.
Sketch3D sketch3 = (Sketch3D)oCompDef.Sketches3D.Add();
SketchEntity3D selectObj = m_oInventorApp.CommandManager.Pick(SelectionFilterEnum.kSketch3DCurveFilter, "Select 3d sketch entity");
if (selectObj == null)
{
}
// HelicalConstraint3D . want to add helical curve around the line above
}
This is iLogic/VB.net code for creating helix curve based on selected SketchLine.
Part document must be active, and at least one SketchLine must be visible for selection.
Sub Main()
Dim oSketchLine As SketchLine = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchCurveLinearFilter,
"Select line")
CreateHelicalCurve(oSketchLine)
End Sub
Private Sub CreateHelicalCurve(oSketchLine As SketchLine)
Dim partDef As PartComponentDefinition = oSketchLine.Parent.Parent
Dim sketch3D As Sketch3D = partDef.Sketches3D.Add()
Dim axisStartPoint As Point = oSketchLine.StartSketchPoint.Geometry3d
Dim axisEndPoint As Point = oSketchLine.EndSketchPoint.Geometry3d
Dim curveStartPoint As Point = axisStartPoint.Copy()
curveStartPoint.TranslateBy(ThisApplication.TransientGeometry.CreateVector(0, 0, 1))
Dim diameter As Double = 5 ' [cm]
Dim pitch As Double = 1 ' [cm]
Dim revolution As Object = Nothing ' Optional argument
Dim height As Double = 5 ' [cm]
Dim helicalCurveDefinition As HelicalCurveConstantShapeDefinition = sketch3D.HelicalCurves.
CreateConstantShapeDefinition(
HelicalShapeDefinitionTypeEnum.kPitchAndHeightShapeType,
axisStartPoint,
axisEndPoint,
curveStartPoint,
diameter,
pitch,
revolution,
height
)
sketch3D.HelicalCurves.Add(helicalCurveDefinition)
End Sub

Right justify header test using TCPDF

This first image shows the standard header layout when using TCPDF:
What I would like to do is right justify the text, as shown below, but I have not been able to figure out how to do this:
Please offer some suggestions! Thanks.
One way to accomplish this is with the writeHTMLCell() method. Setting the $w parameter to 0 will cause the cell to extend to the right margin. The $align parameter can then be set to 'R', which will right-align the cell content.
Example
$html = '<strong>Header Title</strong><br/>
Header string, Line 1<br/>
Header string, Line 2<br/>
Header string, Line 3';
$pdf->writeHTMLCell(
$w=0,
$h=0,
$x=0,
$y=10,
$html,
$border=0,
$ln=0,
$fill=false,
$reseth=true,
$align='R'
);
Working Example
This full example can be run in the TCPDF examples directory.
<?php
require_once('tcpdf_include.php');
class MYPDF extends TCPDF
{
public function Header()
{
$image_file = K_PATH_IMAGES.'logo_example.jpg';
$this->Image($image_file, 10, 10, 15, '', 'JPG');
$html = '<strong>Header Title</strong><br/>
Header string, Line 1<br/>
Header string, Line 2<br/>
Header string, Line 3';
$this->writeHTMLCell(
$w=0,
$h=0,
$x=0,
$y=10,
$html,
$border=0,
$ln=0,
$fill=false,
$reseth=true,
$align='R'
);
}
}
$pdf = new MYPDF();
$pdf->AddPage();
$pdf->Output('example.pdf', 'I');

PHP: Add video tag to youtube link fron content

I have variable $post->post_content that return me detail of post and some video URL from YouTube.
I need to remove any text from $post->post_content else YouTube link, And add to YouTube likn this tag
<video>YouTube_URL</video>
the content like :-
At this instant, while Daggoo, on the summit of the head, was clearing the whip—which had somehow got foul of the great cutting tackles—a sharp cracking noise was heard; and to the unspeakable horror of all, one of the two enormous hooks suspending the head tore out, and with a vast vibration the enormous mass sideways swung, till the drunk ship reeled and shook as if smitten by an iceberg. The one remaining hook, upon which the entire strain now depended, seemed every instant to be on the point of giving way; an event still more likely from the violent motions of the head.
https://www.youtube.com/watch?v=JEreM0ZKY18
and some time like :-
أسر شعار اسبوعين الدولارات من, شرسة أعلنت اندلاع إذ هذا. وبعد الثالث أوكيناوا ما بين, الحصار الأمامية بـ عدد. ذات بقعة فمرّ إذ, أخذ كل بالحرب وسمّيت المانيا. و فصل بمباركة المقيتة, أملاً الحصار المتاخمة من عدد. بزمام أثره، التبرعات تم بعد, الجيش خصوصا كانتا ان دار.
https://www.youtube.com/watch?v=JEreM0ZKY18
My code:
$posts = query_posts('showposts='.$numposts.'&cat=19');
foreach ($posts as $post) {
$postOutput1 = preg_replace('#<a[^>]+>([\r\n|\n]+)?<img[^>]+>([\r\n|\n]+)?<\/a>#','', $post->post_content);
$postOutput2 = preg_replace('#https?://(www\.)?youtube.com/.[^\s.,"\']+#i','', $postOutput1);
$postOutput = preg_replace('[youtube','', $postOutput2);
preg_match_all('#https?://(www\.)?youtube.com/.[^\s.,"\']+#i', $post->post_content, $matches);
foreach($matches as $match){
echo "<video>$match</video>";
}}
How can do that.?
Try this:
$string = "At this instan ... https://www.youtube.com/watch?v=JEreM0ZKY18"
$pattern = '/(http\S*)/im';
$array = array();
preg_match($pattern, $string, $array);
$link = $array[0];
print $link;

JGraphx : How to avoid adding edges over each other?

I'm working on an application using jGraphx and I want to know how to avoid creating edges over each other.
When I add 2 edges between 2 vetexes, the 2 edges are above eatch other..
Thanks in advance.
EDIT : That's what I get, those are 2 edges with the labels : "dist = 1" and "dist = 4" above each other.
It can be done easily:
new mxCircleLayout(graph).execute(graph.getDefaultParent());
new mxParallelEdgeLayout(graph).execute(graph.getDefaultParent());
Without seeing any of your source code it's hard to offer specific details, but in general, what you need to do is get the graph's stylesheet, and then modify the edge related parameters. An example is:
mxGraph mxgraph = new mxGraph();
Object parent = mxgraph.getDefaultParent();
mxgraph.getModel().beginUpdate();
mxStylesheet stylesheet = mxgraph.getStylesheet();
Hashtable<String, Object> style = new Hashtable<>();
stylesheet.putCellStyle("ROUNDED", style);
Map<String, Object> vertexStyle = stylesheet.getDefaultVertexStyle();
vertexStyle.put(mxConstants.STYLE_FILLCOLOR, "#FFFFFF");
vertexStyle.put(mxConstants.STYLE_STROKECOLOR, "#000000");
vertexStyle.put(mxConstants.STYLE_AUTOSIZE, 1);
vertexStyle.put(mxConstants.STYLE_SPACING, "10");
vertexStyle.put(mxConstants.STYLE_ORTHOGONAL, "true");
vertexStyle.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE);
Map<String, Object> edgeStyle = stylesheet.getDefaultEdgeStyle();
edgeStyle.put(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL);
edgeStyle.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_CURVE);
edgeStyle.put(mxConstants.STYLE_ENDARROW, mxConstants.ARROW_CLASSIC);
...set up your edges and vertices here, where the last parameter is "ROUNDED" (the name of the stylesheet)
mxgraph.getModel().endUpdate();

How to vary the width of TextBox views using Rikulo Anchor Layout

I am new to Dart and Rikulo.
class NameView extends Section
{
View parentVu;
// the inputs
DropDownList titleDdl, suffixDdl;
TextBox firstNameTBox, middleNameTBox, lastNameTBox;
// the labels
TextView titleLbl, firstNameLbl, middleNameLbl, lastNameLbl, suffixLbl;
List<String> titles = [ 'Dr', 'Hon', 'Miss', 'Mr', 'Mrs', 'Prof', 'Sir' ];
List<String> suffixes = ['I', 'II', 'III', 'IV', 'Junior', 'Senior'];
NameView()
{
parentVu = new View()
..style.background = 'cyan'
..addToDocument();
titleLbl = new TextView( 'Title' );
parentVu.addChild( titleLbl );
titleDdl = new DropDownList( model : new DefaultListModel( titles ) )
..profile.anchorView = titleLbl
..profile.location = 'east center';
parentVu.addChild( titleDdl );
firstNameLbl = new TextView( 'First' )
..profile.anchorView = titleDdl
..profile.location = 'east center';
parentVu.addChild(firstNameLbl );
firstNameTBox = new TextBox( null, 'text' )
..profile.anchorView = firstNameLbl
..profile.location = 'east center';
//..profile.width = 'flex';
parentVu.addChild( firstNameTBox );
}
The program renders. However, it does not uses the entire width of the browser (FireFox).
I have tried for the TextBoxes
profile.width = 'flex'
but it does not work.
Any help is appreciated.
Firefox? Did you test it with Dartium? Notice that you have to compile it to JS before you can test it with browsers other than Dartium.
BTW, from your implementation, NameView seems not related to parentVu at all. If it is just a controller, it needs not to extend from Section (i.e., it doesn't have to be a view).
If a view is anchored to another, both location and size will depend on the view it anchors. In your case, if specifying flex to TextBox, its width will be the same as FirstNameLb1. It is why it is so small.
You can listen to the layout event such as:
firstNameTBox.on.layout.listen((_) {
firstNameTBox.width = parentVu.width;
});
Note: You need to do some calculation to get the right width.
See also Layout Overview

Resources