How do you set a custom line end in visio? - java

I'm writing a visio export and created a visio template file containing custom line endings. When I try to set those using code, it is not working.
//Create two shapes
final IVMaster lApp = stencilObj.masters("Application");
IVShape shapeFrom = pagObj.drop(lApp, 1, 1);
IVShape shapeTo = pagObj.drop(lApp, 2, 3);
//Connect the shapes
final IVMaster connMaster = stencilObj.masters("Connection");
IVShape connection = pagObj.drop(connMaster, 2, 3);
final IVCell gluefrom1 = connection.cells("BeginX");
final IVCell glueat1 = shapeFrom.cells("PinX");
gluefrom1.glueTo(glueat1);
final IVCell gluefrom2 = connection.cells("EndX");
final IVCell glueat2 = shapeTo.cells("PinX");
gluefrom2.glueTo(glueat2);
//Set arrow ending
connection.cellsU("EndArrow").formulaForceU(new Integer(46).toString());
So there are 45 default line endings in visio and the 46th in the list is mine. When I'm setting number 45 it works, number 46 doesn't.
When I right click on the connection and go to Format->Line, the correct line ending is selected and the Preview is also correct. I have to select the ending again and click apply for it to be updated in the document.
I'm working with Visio 2007

Ok I found the problem. You need to use the full name for the line ending and call a visio function with it.
//Set arrow ending
connection.cellsU("EndArrow").formula("=USE(\"46: interface_in\")");

Related

DynamicJasper - UTF-8 character not showed

I'm using DynamicJasper to generate Pdf files.
In the application.properties file I have a property with this value:
reports.info = To get information call 📞 5555-1234
For that, I'm using a AutoText, to put that in the footer.
AutoText info = new AutoText(messageSupportHelper.getMessage("reports.info1"),
AutoText.POSITION_FOOTER, HorizontalBandAlignment.CENTER);
info.setWidth(700);
info.setStyle(createTitleHeaderStyle());
And the method of the style is:
private Style createTitleHeaderStyle() {
Style style = Style.createBlankStyle("ASDASDASDASD");
style.setFont(new Font(7, DEJA_VU_SANS, true, false, false));
style.getFont().setPdfFontEncoding(Font.PDF_ENCODING_Identity_H_Unicode_with_horizontal_writing);
style.getFont().setPdfFontEmbedded(true);
style.setTextColor(new Color(60, 153, 124));
style.setBackgroundColor(Color.WHITE);
style.setVerticalAlign(VerticalAlign.MIDDLE);
return style;
}
But phone icon is not showed in the pdf file.
I tried also these ways:
reports.info = To get information call 📞 5555-1234
reports.info = To get information call 📞 5555-1234
reports.info = To get information call \uD83D\uDCDE 5555-1234
But I have the same result.
Do you know what is happening?

Text Formatting is changed while Sharing data: Android

I want to share diamond detail in table format(Plain text not HTML)
I have made this using this library but its prints the data properly using the system.out but while I sharing it, its format is changed:
Below is my code:
List<String> headersList = Arrays.asList("", "");
List<List<String>> rowsList = Arrays.asList(
Arrays.asList("Stone Id :", details[0]),
Arrays.asList("Lab", details[1]),
Arrays.asList("Shape", details[2]),
Arrays.asList("Carat", details[3]),
Arrays.asList("Clarity-Color", details[4]),
Arrays.asList("Cut-Pol-Sym-Flou", details[5]));
Board board = new Board(75);
Table table = new Table(board, 75, headersList, rowsList);
table.invalidate().setGridMode(Table.GRID_NON).setRowsList(rowsList);
List<Integer> colWidthsList = Arrays.asList(30, 14);
table.setColWidthsList(colWidthsList);
Block tableBlock = table.tableToBlocks();
board.setInitialBlock(tableBlock);
board.build();
String preview1 = board.getPreview();
System.out.print(preview1);
sharingIntent.putExtra(Intent.EXTRA_TEXT,preview1);
The console uses monospaced font which takes exactly same width for all characters. But your view isn't using it, so it looks messed up.
Use a monospaced font.
Or use a tabular format. Perhaps a ListView with each row having two text views side by side having fixed width.

Function works only in Debug Mode MATLAB GUI

I'm trying to create a calendar using MATLAB GUI.
I found this tutorial and created calendar:
com.mathworks.mwswing.MJUtilities.initJIDE;
% Put calendar to my figure
jPanel = com.jidesoft.combobox.DateChooserPanel;
[hPanel,hContainer] = javacomponent(jPanel,[500,130,200,200],gcf);
set(handles.hPanel, 'MousePressedCallback', ...
#(src, evnt)CellSelectionCallback(src, evnt, handles));
set(handles.hPanel, 'KeyPressedCallback', ...
#(src, evnt)CellSelectionCallback(src, evnt, handles));
Also I have Edit Text object. Lets try to put Selected Value to it!
I use excaza's code:
function CellSelectionCallback(hObject, evnt, handles)
hModel = handle(hObject.getSelectionModel, 'CallbackProperties');
selectedDate = hModel.getSelectedDate();
dayNumber = get(selectedDate,'Date');
handles.edit_start.String = num2str(dayNumber);
handles.newNote(3) = {dayNumber};
guidata(handles.figure1, handles);
So I can read selected date and put it anywhere.
Problem
Code works only in Debug Mode. In normal mode my Edit Text Object (edit_start) stays empty!

Change image object on template using Brother print Android SDK

I have set up label printing from our app using the b-PAC Android SDK (Java). Using the code below I can replace the text from my template with what I want.
// Start creating P-touch Template command print data
Boolean val= myPrinter.startPTTPrint(6, null);
Log.i("print", "startPTTPrint "+val);
// Replace text
myPrinter.replaceText("abcde");
// Trasmit P-touch Template command print data
PrinterStatus status=myPrinter.flushPTTPrint();
I am now trying to replace an image object within the template. I know it can be done in VBScript using:
bpac.Object ob = doc.GetObject("Photo");
ob.SetData(0, #"C:\Photo\635466380534236711.png", 4);
I can't find any Java examples of this within the b-PAC 3.1 SDK help guide and I have only just began coding in Java so I am very much a novice.
Does anyone have experience with the Brother SDK/Java who can point me in the right direction?
Thanks!
I got this working
Basically I have a template that I copy to an new file on which I make the changes
The image object in the template is called imgPart, the other objects are textblocks
Dim m_partNum As String = "12345"
Dim m_PartName As String = "Plate Special 1 x 2" & vbCrLf & "4 Studs"
Dim m_PartImage As String = "c:\Danny\myLego\Labels\PartImages\3033.png"
Dim m_template As String = "c:\Danny\myLego\Templates\PRINTME.lbx"
Dim m_target As String = "c:\Danny\myLego\Templates\" & m_partNum & ".lbx"
Dim doc As bpac.DocumentClass = New bpac.DocumentClass
Try
File.Copy(m_template, m_target, vbTrue)
If doc.Open(m_target) <> False Then
doc.GetObject("imgPart").SetData(0, m_PartImage, 4)
doc.GetObject("txtPartName").Text = m_PartName
doc.GetObject("txtPartNum").Text = m_partNum
doc.Save()
doc.Close()
Else
MsgBox("Open Error on Receipt with error")
End If
Catch ex As Exception
MsgBox("Error occurred : " & ex.ToString)
End Try

How to add PPT notes using docx4j

I am creating PPT files using the library docx4j. I have been able to create slides with text and images, but I have not been able to add notes to them.
I am creating the slide like this:
MainPresentationPart pp = (MainPresentationPart)presentationParts.get(new PartName("/ppt/presentation.xml"));
SlideLayoutPart layoutPart = (SlideLayoutPart)presentationParts.get(new PartName("/ppt/slideLayouts/slideLayout1.xml"));
SlidePart slidePart = PresentationMLPackage.createSlidePart(pp, layoutPart, new PartName("/ppt/slides/slide" + ++slideNumber + ".xml"));
so I can add text or images to the body, but when I try to access the field slidePart.notes it is null. I have tried to initialize it
slidePart.setPartShortcut(new NotesSlidePart());
but then everything inside notes is null and I have not achieved anything.
So, does anyone have a working example of how to add notes to a PPT file?
Many thanks
Its not enough to do:
slidePart.setPartShortcut(new NotesSlidePart());
You need to explicitly add the notes slide part to your slide part (so that the relationships get set up correctly), by invoking addTargetPart.
But there's more you have to do given the way the pptx format works. To see what parts are required, upload a pptx to the docx4j webapp. Here's the code I wrote just now based on doing that:
// Now add notes slide.
// 1. Notes master
NotesMasterPart nmp = new NotesMasterPart();
NotesMaster notesmaster = (NotesMaster)XmlUtils.unmarshalString(notesMasterXml, Context.jcPML);
nmp.setJaxbElement(notesmaster);
// .. connect it to /ppt/presentation.xml
Relationship ppRelNmp = pp.addTargetPart(nmp);
/*
* <p:notesMasterIdLst>
<p:notesMasterId r:id="rId3"/>
</p:notesMasterIdLst>
*/
pp.getJaxbElement().setNotesMasterIdLst(createNotesMasterIdListPlusEntry(ppRelNmp.getId()));
// .. NotesMasterPart typically has a rel to a theme
// .. can we get away without it?
// Nope .. read this in from a file
ThemePart themePart = new ThemePart(new PartName("/ppt/theme/theme2.xml"));
// TODO: read it from a string instead
themePart.unmarshal(
FileUtils.openInputStream(new File(System.getProperty("user.dir") + "/theme2.xml"))
);
nmp.addTargetPart(themePart);
// 2. Notes slide
NotesSlidePart nsp = new NotesSlidePart();
Notes notes = (Notes)XmlUtils.unmarshalString(notesXML, Context.jcPML);
nsp.setJaxbElement(notes);
// .. connect it to the slide
slidePart.addTargetPart(nsp);
// .. it also has a rel to the slide
nsp.addTargetPart(slidePart);
// .. and the slide master
nsp.addTargetPart(nmp);
You can find the complete example at https://github.com/plutext/docx4j/blob/master/src/samples/pptx4j/org/pptx4j/samples/SlideNotes.java

Categories

Resources