Using blankCursor in vlcj when vlc is playing - vlcj

Using the EmbeddedMediaPlayerComponent of vlcj 3.2.0 the cursor can be disabled with this.setCursorEnabled(false); but this only works on the canvas.
If VLC is playing via vlcj, the cursor seems to become the default cursor and stays for the default VLC time (1000ms) until the cursor disappears.
Using VLC directly, the cursor time can be set to 0ms.
How can I make the cursor disappear using vlcj. Either setting time to 0ms or using blankCursor?

If you want to use the VLC "--mouse-hide-timeout=0" switch with vlcj then you can do that by overriding the media player factory arguments.
By default, the EmbeddedMediaPlayerComponent has these factory arguments:
protected static final String[] DEFAULT_FACTORY_ARGUMENTS = {
"--video-title=vlcj video output",
"--no-snapshot-preview",
"--quiet-synchro",
"--sub-filter=logo:marq",
"--intf=dummy"
};
The component class is designed to be sub-classed, one of the methods you can override allows you to set your own factory arguments:
mp = new EmbeddedMediaPlayerComponent() {
#Override
protected String[] onGetMediaPlayerFactoryArgs() {
return new String[] {
"--video-title=vlcj video output",
"--no-snapshot-preview",
"--quiet-synchro",
"--sub-filter=logo:marq",
"--intf=dummy",
"--mouse-hide-timeout=0"
};
}
};
Here we have added --mouse-hide-timeout=0.
That's a bit ugly because we have to provide the default arguments too. With vlcj 3.5.0 it's a bit easier if you want to preserve those default arguments:
mp = new EmbeddedMediaPlayerComponent() {
#Override
protected String[] onGetMediaPlayerFactoryExtraArgs() {
return new String[] {
"--mouse-hide-timeout=0"
};
}
};
There may also be a much simpler way...
Make sure you call mediaPlayer.setCursorEnabled(false) before you show the window that contains your media player.

Related

PdfCleanUpTool SetRedactionColor

Is there a way to use PdfCleanUpTool so that the RedactionColor is transparent (i.e., it çshows the color of the actual background), instead of having to choose one.
I don't know why, but using PdfCleanUpTool.CleanUp() crashed (after adding the locations). However, this did the job (PdfCleaner.AutoSweepCleanUp):
public static void RemoveTexts(PdfDocument pdfDoc, List<Regex> regexes)
{
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
foreach (Regex rgx in regexes)
{
RegexBasedCleanupStrategy rbCS = new RegexBasedCleanupStrategy(rgx);
rbCS.SetRedactionColor(null);
strategy.Add(rbCS);
}
PdfCleaner.AutoSweepCleanUp(pdfDoc, strategy);
}

Android Viewpager to load images from SD Card

Guys Im using the following custom code to load 20 images from resources and present in a viewpager
public class CustomPagerAdapter extends PagerAdapter {
int[] mResources = {
R.drawable.slide1,
R.drawable.slide2,
R.drawable.slide3,
R.drawable.slide4,
R.drawable.slide5,
R.drawable.slide6,
R.drawable.slide7,
R.drawable.slide8,
R.drawable.slide9,
R.drawable.slide10,
R.drawable.slide11,
R.drawable.slide12,
R.drawable.slide13,
R.drawable.slide14,
R.drawable.slide15,
R.drawable.slide16,
R.drawable.slide17,
R.drawable.slide18,
R.drawable.slide19,
R.drawable.slide20,
};
Context mContext;
LayoutInflater mLayoutInflater;
public CustomPagerAdapter(Context context) {
mContext = context;
mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return mResources.length;
}
#Override
public boolean isViewFromObject(View view, Object object) {
return view == ((LinearLayout) object);
}
#Override
public Object instantiateItem(ViewGroup container, int position) {
View itemView = mLayoutInflater.inflate(R.layout.pager_item, container, false);
ImageView imageView = (ImageView) itemView.findViewById(R.id.imageView);
imageView.setImageResource(mResources[position]);
container.addView(itemView);
return itemView;
}
#Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((LinearLayout) object);
}
}
This works fine but I want to put the jpgs in a directory on the device so that they can be changed without recompiling the app
I think I need to get the images into the mResource array. I can get the path but not sure what format the code should be instead of using the draw-able lines
i have read articles on here but none make sense to me I am really new to this and the code looks nothing like the code I am using
can anyone point me in the right direction?
Any help is greatly appreciated
Mark
Yes, you can certainly do so. I will try to explain you the process step-by-step,
Step 1
Have a File object pointing to the path, like,
File directory = new File("path-to-directory");
Ensure that the path is to the directory with the images,
Step 2
List all the files inside the directory using listFiles() method, like
File[] allImages = directory.listFiles();
Now you have an array of all the files just like int[] mResources. The only difference being, now you have actual file references, while previously you had resource ids.
Step 3
You can just display the images in the ViewPager just like you did previously. But this is a bit tricky and can take you a considerable amount of time and code to get an image properly displayed from File.
You also need to take care of caching, so that when you load a previously loaded image again, it gets it from the cache.
To do all this, I recommend you to use this library (recommended by Google), Glide.
Setting an image is one line of code,
Glide.with(context).from(file).into(imageView);
That's it. Now you have your images displayed in a ViewPager from a directory in the device.

How to register a Renderer with CRaSH

After reading about the remote shell in the Spring Boot documentation I started playing around with it. I implemented a new Command that produces a Stream of one of my database entities called company.
This works fine. So I want to output my stream of companies in the console. This is done by calling toString() by default. While this seams reasonable there is also a way to get nicer results by using a Renderer.
Implementing one should be straight forward as I can delegate most of the work to one of the already existing ones. I use MapRenderer.
class CompanyRenderer extends Renderer<Company> {
private final mapRenderer = new MapRenderer()
#Override Class<Company> getType() { Company }
#Override LineRenderer renderer(Iterator<Company> stream) {
def list = []
stream.forEachRemaining({
list.add([id: it.id, name: it.name])
})
return mapRenderer.renderer(list.iterator())
}
}
As you can see I just take some fields from my entity put them into a Mapand then delegate to a instance of MapRenderer to do the real work.
TL;DR
Only problem is: How do I register my Renderer with CRaSH?
Links
Spring Boot documentation http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-remote-shell.html
CRaSH documentation (not helping) http://www.crashub.org/1.3/reference.html#_renderers

javafx8 timeline - how to get the source of the animation

I want to have 3 objects doing different things, so I want to get the source of the caller.
I am using lambda for that, and I am not using key frame, the animation is the same and cyclic so I don't need to specify different behavior for a different key frame.
Maybe I am doing something wrong with the lambda?
this is my code:
class MyClock extends ClockPane //clockpane extends pane
{
Timeline animation;
int id;
EventHandler<ActionEvent> eventHandler = e ->
{//startAnimationById();
System.out.println(e.getSource()==clockControl1.myclock.animation);
};
public MyClock(int c,int id)
{
super(c);
this.id=id;
animation = new Timeline(new KeyFrame(Duration.millis(1000),eventHandler));
animation.setCycleCount(Timeline.INDEFINITE);
animation.play();
}
the startanimationbyid method works using the id I defined to avoid this problem, but it surely does bug me.
I have 3 different objects of this type, each one is nested ina clockcontrol class
(in other words I have clockcontrol1 clockcontrol2 and 3 each one of these having a MyClock myclock in them)
The print I have there returns false for all the the clocks I have (total of 3) while as it is currently written I'd expect to get true for the first clock...I tried different variations of this, the one I post here is only the last variation, but I got false for all of my attempts.
Where did I mess things up?
The API for KeyFrame doesn't specify what the source of the ActionEvent will be. You could just do System.out.println(e.getSource()) to see (it seems that the source of the event is the KeyFrame object, not the animation), but there's no real guarantee it would always be what you expect.
If you want different instances of MyClock to behave differently, you can provide a parameter for the different behavior. In this case, you could use a Runnable to execute different code in the event handler:
class MyClock extends ClockPane //clockpane extends pane
{
Timeline animation;
// int id;
public MyClock(int c, Runnable handler)
{
super(c);
EventHandler<ActionEvent> eventHandler = e -> handler.run() ;
animation = new Timeline(new KeyFrame(Duration.millis(1000),eventHandler));
animation.setCycleCount(Timeline.INDEFINITE);
animation.play();
}
}
Then you can instantiate these as you need:
public class Controller1 {
// ...
MyClock clock = new MyClock(..., () -> {
// code to execute for this clock
});
}
and
public class Controller2 {
// ...
MyClock clock = new MyClock(..., () -> {
// code to execute for this clock
});
}

How to add DropListener to drop text in a draw2d Label

I am Trying to add a dropListener so I can Drop and text into a draw2d Label ,in GEf Editor , Can anyone help how Can I do that. An example will be great.
To respond to drop events on a GEF edit part viewer you have to install on the viewer itself an implementation of org.eclipse.jface.util.TransferDropTargetListener that understands transfers of type org.eclipse.swt.dnd.TextTransfer and that creates some kind of org.eclipse.gef.Request that can be handled by an org.eclipse.gef.EditPolicy installed on the target org.eclipse.gef.EditPart.
You have to understand that both the Request and the EditPolicy allow you to customize the drop behavior on a EditPart basis. As a consequence, I can show you an example that is actually fully functional, but feel free to customize it to your real needs.
First create the TransferDropTargetListener:
public class TextTransferDropTargetListener extends AbstractTransferDropTargetListener {
public TextTransferDropTargetListener(EditPartViewer viewer) {
super(viewer, TextTransfer.getInstance());
}
#Override
protected void handleDragOver() {
getCurrentEvent().feedback = DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
super.handleDragOver();
}
#Override
protected Request createTargetRequest() {
return new ChangeBoundsRequest(REQ_ADD);
}
#Override
protected void updateTargetRequest() {
ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
request.setEditParts(Collections.EMPTY_LIST);
request.setLocation(getDropLocation());
}
#Override
protected void handleDrop() {
super.handleDrop();
if (getCurrentEvent().detail != DND.DROP_NONE) {
getViewer().setSelection(StructuredSelection.EMPTY);
getViewer().getControl().setFocus();
}
}
#Override
protected Command getCommand() {
String text = (String) getCurrentEvent().data;
List<IEntityPart> editParts = new ArrayList<IEntityPart>();
//
// using the 'text' variable you have to create
// a new EditPart that would eventually replace the old one.
//
editParts.add(createNewLabelPart());
ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
request.setEditParts(editParts);
return super.getCommand();
}
}
then install the listener in the graphical viewer constructor using the following statement:
addDropTargetListener(new TextTransferDropTargetListener(this));
finally ensure that an EditPolicy that understands requests of type REQ_ADD (maybe you already added one that extends LayoutEditPolicy or ContainerEditPolicy) is installed on the target EditPart, which is usually done in the AbstractEditPart.createEditPolicies().
To better understand the chain of responsibilities, I suggest you to have a look at the super implementation of the TransferDropTargetListener.getCommand() method.

Resources